[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[taler-anastasis] branch master updated: child management is now in GNUn
From: |
gnunet |
Subject: |
[taler-anastasis] branch master updated: child management is now in GNUnet, remove from ANASTASIS |
Date: |
Mon, 03 May 2021 16:27:11 +0200 |
This is an automated email from the git hooks/post-receive script.
grothoff pushed a commit to branch master
in repository anastasis.
The following commit(s) were added to refs/heads/master by this push:
new 8d897a0 child management is now in GNUnet, remove from ANASTASIS
8d897a0 is described below
commit 8d897a0281a42938a7766c17d254544445cbf168
Author: Christian Grothoff <christian@grothoff.org>
AuthorDate: Mon May 3 16:27:09 2021 +0200
child management is now in GNUnet, remove from ANASTASIS
---
doc/anastasis.pdf | Bin 1775690 -> 0 bytes
.../anastasis_authorization_plugin_email.c | 10 +-
.../anastasis_authorization_plugin_post.c | 10 +-
.../anastasis_authorization_plugin_sms.c | 10 +-
src/util/Makefile.am | 12 +-
src/util/child_management.c | 212 ---------------------
src/util/child_management_test.sh | 2 -
src/util/test_anastasis_child_management.c | 178 -----------------
8 files changed, 16 insertions(+), 418 deletions(-)
diff --git a/doc/anastasis.pdf b/doc/anastasis.pdf
deleted file mode 100644
index fd96681..0000000
Binary files a/doc/anastasis.pdf and /dev/null differ
diff --git a/src/authorization/anastasis_authorization_plugin_email.c
b/src/authorization/anastasis_authorization_plugin_email.c
index 46c8eb2..586460b 100644
--- a/src/authorization/anastasis_authorization_plugin_email.c
+++ b/src/authorization/anastasis_authorization_plugin_email.c
@@ -94,7 +94,7 @@ struct ANASTASIS_AUTHORIZATION_State
/**
* Handle to wait for @e child
*/
- struct ANASTASIS_ChildWaitHandle *cwh;
+ struct GNUNET_ChildWaitHandle *cwh;
/**
* Our client connection, set if suspended.
@@ -388,9 +388,9 @@ email_process (struct ANASTASIS_AUTHORIZATION_State *as,
}
GNUNET_DISK_file_close (pipe_stdin);
}
- as->cwh = ANASTASIS_wait_child (as->child,
- &email_done_cb,
- as);
+ as->cwh = GNUNET_wait_child (as->child,
+ &email_done_cb,
+ as);
as->connection = connection;
MHD_suspend_connection (connection);
return ANASTASIS_AUTHORIZATION_RES_SUSPENDED;
@@ -490,7 +490,7 @@ email_cleanup (struct ANASTASIS_AUTHORIZATION_State *as)
{
if (NULL != as->cwh)
{
- ANASTASIS_wait_child_cancel (as->cwh);
+ GNUNET_wait_child_cancel (as->cwh);
as->cwh = NULL;
}
if (NULL != as->child)
diff --git a/src/authorization/anastasis_authorization_plugin_post.c
b/src/authorization/anastasis_authorization_plugin_post.c
index c77ac03..ac1e738 100644
--- a/src/authorization/anastasis_authorization_plugin_post.c
+++ b/src/authorization/anastasis_authorization_plugin_post.c
@@ -88,7 +88,7 @@ struct ANASTASIS_AUTHORIZATION_State
/**
* Handle to wait for @e child
*/
- struct ANASTASIS_ChildWaitHandle *cwh;
+ struct GNUNET_ChildWaitHandle *cwh;
/**
* Our client connection, set if suspended.
@@ -460,9 +460,9 @@ post_process (struct ANASTASIS_AUTHORIZATION_State *as,
}
GNUNET_DISK_file_close (pipe_stdin);
}
- as->cwh = ANASTASIS_wait_child (as->child,
- &post_done_cb,
- as);
+ as->cwh = GNUNET_wait_child (as->child,
+ &post_done_cb,
+ as);
as->connection = connection;
MHD_suspend_connection (connection);
return ANASTASIS_AUTHORIZATION_RES_SUSPENDED;
@@ -545,7 +545,7 @@ post_cleanup (struct ANASTASIS_AUTHORIZATION_State *as)
{
if (NULL != as->cwh)
{
- ANASTASIS_wait_child_cancel (as->cwh);
+ GNUNET_wait_child_cancel (as->cwh);
as->cwh = NULL;
}
if (NULL != as->child)
diff --git a/src/authorization/anastasis_authorization_plugin_sms.c
b/src/authorization/anastasis_authorization_plugin_sms.c
index 70bcff7..e59d3e0 100644
--- a/src/authorization/anastasis_authorization_plugin_sms.c
+++ b/src/authorization/anastasis_authorization_plugin_sms.c
@@ -93,7 +93,7 @@ struct ANASTASIS_AUTHORIZATION_State
/**
* Handle to wait for @e child
*/
- struct ANASTASIS_ChildWaitHandle *cwh;
+ struct GNUNET_ChildWaitHandle *cwh;
/**
* Our client connection, set if suspended.
@@ -385,9 +385,9 @@ sms_process (struct ANASTASIS_AUTHORIZATION_State *as,
}
GNUNET_DISK_file_close (pipe_stdin);
}
- as->cwh = ANASTASIS_wait_child (as->child,
- &sms_done_cb,
- as);
+ as->cwh = GNUNET_wait_child (as->child,
+ &sms_done_cb,
+ as);
as->connection = connection;
MHD_suspend_connection (connection);
return ANASTASIS_AUTHORIZATION_RES_SUSPENDED;
@@ -482,7 +482,7 @@ sms_cleanup (struct ANASTASIS_AUTHORIZATION_State *as)
{
if (NULL != as->cwh)
{
- ANASTASIS_wait_child_cancel (as->cwh);
+ GNUNET_wait_child_cancel (as->cwh);
as->cwh = NULL;
}
if (NULL != as->child)
diff --git a/src/util/Makefile.am b/src/util/Makefile.am
index 36ee196..fdc92c9 100644
--- a/src/util/Makefile.am
+++ b/src/util/Makefile.am
@@ -31,7 +31,6 @@ lib_LTLIBRARIES = \
libanastasisutil_la_SOURCES = \
anastasis_crypto.c \
- child_management.c \
os_installation.c
libanastasisutil_la_LIBADD = \
-lgnunetutil \
@@ -44,20 +43,11 @@ libanastasisutil_la_LDFLAGS = \
-export-dynamic -no-undefined
check_PROGRAMS = \
- test_anastasis_crypto \
- test_anastasis_child_management
+ test_anastasis_crypto
TESTS = \
$(check_PROGRAMS)
-test_anastasis_child_management_SOURCES = \
- test_anastasis_child_management.c
-test_anastasis_child_management_LDADD = \
- -lgnunetutil \
- -ltalerutil \
- libanastasisutil.la \
- $(XLIB)
-
test_anastasis_crypto_SOURCES = \
test_anastasis_crypto.c
test_anastasis_crypto_LDADD = \
diff --git a/src/util/child_management.c b/src/util/child_management.c
deleted file mode 100644
index 267b4db..0000000
--- a/src/util/child_management.c
+++ /dev/null
@@ -1,212 +0,0 @@
-/*
- This file is part of Anastasis
- Copyright (C) 2020 Taler Systems SA
-
- Anastasis is free software; you can redistribute it and/or modify it under
the
- terms of the GNU Lesser General Public License as published by the Free
Software
- Foundation; either version 3, or (at your option) any later version.
-
- Anastasis is distributed in the hope that it will be useful, but WITHOUT ANY
- WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
- A PARTICULAR PURPOSE. See the GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License along with
- Anastasis; see the file COPYING.GPL. If not, see
<http://www.gnu.org/licenses/>
-*/
-/**
- * @file util/child_management.c
- * @brief anastasis child management
- * @author Christian Grothoff
- * @author Dominik Meister
- */
-#include "platform.h"
-#include "anastasis_util_lib.h"
-
-
-/**
- * Struct which defines a Child Wait handle
- */
-struct ANASTASIS_ChildWaitHandle
-{
- /**
- * Linked list to the next child
- */
- struct ANASTASIS_ChildWaitHandle *next;
- /**
- * Linked list to the previous child
- */
- struct ANASTASIS_ChildWaitHandle *prev;
- /**
- * Child process which is managed
- */
- struct GNUNET_OS_Process *proc;
- /**
- * Callback which is called upon completion/death of the child task
- */
- ANASTASIS_ChildCompletedCallback cb;
- /**
- * Closure for the handle
- */
- void *cb_cls;
-};
-
-
-/**
- * Pipe used to communicate shutdown via signal.
- */
-static struct GNUNET_DISK_PipeHandle *sigpipe;
-
-static struct GNUNET_SIGNAL_Context *shc_chld;
-
-static struct GNUNET_SCHEDULER_Task *sig_task;
-
-static struct ANASTASIS_ChildWaitHandle *cwh_head;
-
-static struct ANASTASIS_ChildWaitHandle *cwh_tail;
-
-/**
- * Task triggered whenever we receive a SIGCHLD (child
- * process died) or when user presses CTRL-C.
- *
- * @param cls closure, NULL
- */
-static void
-maint_child_death (void *cls)
-{
- char buf[16];
- const struct GNUNET_DISK_FileHandle *pr;
- struct ANASTASIS_ChildWaitHandle *nxt;
-
- (void) cls;
- sig_task = NULL;
- /* drain pipe */
- pr = GNUNET_DISK_pipe_handle (sigpipe,
- GNUNET_DISK_PIPE_END_READ);
- GNUNET_assert (! GNUNET_DISK_handle_invalid (pr));
-
- (void) GNUNET_DISK_file_read (pr,
- buf,
- sizeof(buf));
-
- /* find applicable processes that exited */
- for (struct ANASTASIS_ChildWaitHandle *cwh = cwh_head;
- NULL != cwh;
- cwh = nxt)
- {
- enum GNUNET_OS_ProcessStatusType type;
- long unsigned int exit_code = 0;
-
- nxt = cwh->next;
- if (GNUNET_OK ==
- GNUNET_OS_process_status (cwh->proc,
- &type,
- &exit_code))
- {
- GNUNET_CONTAINER_DLL_remove (cwh_head,
- cwh_tail,
- cwh);
- cwh->cb (cwh->cb_cls,
- type,
- exit_code);
- GNUNET_free (cwh);
- }
- }
- if (NULL == cwh_head)
- return;
- /* wait for more */
- sig_task = GNUNET_SCHEDULER_add_read_file (
- GNUNET_TIME_UNIT_FOREVER_REL,
- GNUNET_DISK_pipe_handle (sigpipe,
- GNUNET_DISK_PIPE_END_READ),
- &maint_child_death,
- NULL);
-}
-
-
-/**
- * Signal handler called for SIGCHLD. Triggers the
- * respective handler by writing to the trigger pipe.
- */
-static void
-sighandler_child_death (void)
-{
- static char c;
- int old_errno = errno; /* back-up errno */
-
- GNUNET_break (
- 1 ==
- GNUNET_DISK_file_write (GNUNET_DISK_pipe_handle (sigpipe,
-
GNUNET_DISK_PIPE_END_WRITE),
- &c,
- sizeof(c)));
- errno = old_errno; /* restore errno */
-}
-
-
-void __attribute__ ((constructor))
-child_management_start ()
-{
- if (NULL != sigpipe)
- return; /* already initialized */
- sigpipe = GNUNET_DISK_pipe (GNUNET_DISK_PF_NONE);
- GNUNET_assert (sigpipe != NULL);
- shc_chld =
- GNUNET_SIGNAL_handler_install (GNUNET_SIGCHLD, &sighandler_child_death);
-}
-
-
-struct ANASTASIS_ChildWaitHandle *
-ANASTASIS_wait_child (struct GNUNET_OS_Process *proc,
- ANASTASIS_ChildCompletedCallback cb,
- void *cb_cls)
-{
- struct ANASTASIS_ChildWaitHandle *cwh;
-
- child_management_start ();
- cwh = GNUNET_new (struct ANASTASIS_ChildWaitHandle);
- cwh->proc = proc;
- cwh->cb = cb;
- cwh->cb_cls = cb_cls;
- GNUNET_CONTAINER_DLL_insert (cwh_head,
- cwh_tail,
- cwh);
- if (NULL == sig_task)
- {
- sig_task = GNUNET_SCHEDULER_add_read_file (
- GNUNET_TIME_UNIT_FOREVER_REL,
- GNUNET_DISK_pipe_handle (sigpipe,
- GNUNET_DISK_PIPE_END_READ),
- &maint_child_death,
- NULL);
- }
- return cwh;
-}
-
-
-void
-ANASTASIS_wait_child_cancel (struct ANASTASIS_ChildWaitHandle *cwh)
-{
- GNUNET_CONTAINER_DLL_remove (cwh_head,
- cwh_tail,
- cwh);
- if (NULL == cwh_head)
- {
- GNUNET_SCHEDULER_cancel (sig_task);
- sig_task = NULL;
- }
- GNUNET_free (cwh);
-}
-
-
-/**
- * Clean up.
- */
-void __attribute__ ((destructor))
-ANASTASIS_CM_done ()
-{
- GNUNET_assert (NULL == sig_task);
- GNUNET_SIGNAL_handler_uninstall (shc_chld);
- shc_chld = NULL;
- GNUNET_DISK_pipe_close (sigpipe);
- sigpipe = NULL;
-}
diff --git a/src/util/child_management_test.sh
b/src/util/child_management_test.sh
deleted file mode 100755
index a35b865..0000000
--- a/src/util/child_management_test.sh
+++ /dev/null
@@ -1,2 +0,0 @@
-#!/usr/bin/env bash
-echo "$1$2" >> child_management_test.txt
diff --git a/src/util/test_anastasis_child_management.c
b/src/util/test_anastasis_child_management.c
deleted file mode 100644
index c16670a..0000000
--- a/src/util/test_anastasis_child_management.c
+++ /dev/null
@@ -1,178 +0,0 @@
-/*
- This file is part of TALER
- Copyright (C) 2014-2020 Taler Systems SA
-
- TALER is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as
- published by the Free Software Foundation; either version 3, or
- (at your option) any later version.
-
- TALER is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public
- License along with TALER; see the file COPYING. If not, see
- <http://www.gnu.org/licenses/>
-*/
-
-/**
- * @file lib/test_anastasis_child_management.c
- * @brief testcase to test the child management
- * @author Christian Grothoff
- * @author Dominik Meister
- */
-#include "platform.h"
-#include <gnunet/gnunet_util_lib.h>
-#include "anastasis_util_lib.h"
-
-
-static struct ANASTASIS_ChildWaitHandle *cwh;
-
-static int global_ret;
-
-static struct GNUNET_OS_Process *pid;
-
-
-static void
-child_completed_callback (void *cls,
- enum GNUNET_OS_ProcessStatusType type,
- long unsigned int exit_code)
-{
- cwh = NULL;
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Process extided with code: %lu \n",
- exit_code);
- FILE *file;
- char code[9];
-
- file = fopen ("child_management_test.txt", "r");
- if (NULL == file)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "could not find file: child_management_test.txt in %s:%u\n",
- __FILE__,
- __LINE__);
- global_ret = 1;
- return;
- }
- if (0 == fscanf (file,
- "%8s",
- code))
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "could not read file: child_management_test.txt in %s:%u\n",
- __FILE__,
- __LINE__);
- global_ret = 1;
- return;
- }
-
- if (0 != strcmp ("12345678", code))
- {
- global_ret = 1;
- return;
- }
- GNUNET_OS_process_destroy (pid);
- pid = NULL;
- GNUNET_break (0 == unlink ("child_management_test.txt"));
- GNUNET_SCHEDULER_shutdown ();
- global_ret = 0;
-}
-
-
-static void
-do_shutdown (void *cls)
-{
- if (NULL != cwh)
- {
- ANASTASIS_wait_child_cancel (cwh);
- cwh = NULL;
- }
- if (NULL != pid)
- {
- GNUNET_assert (0 ==
- GNUNET_OS_process_kill (pid,
- SIGKILL));
- GNUNET_assert (GNUNET_OK ==
- GNUNET_OS_process_wait (pid));
- GNUNET_OS_process_destroy (pid);
- pid = NULL;
- }
-}
-
-
-static void
-test_child_management (void *cls)
-{
- const char *command = "./child_management_test.sh";
- struct GNUNET_DISK_PipeHandle *p;
- struct GNUNET_DISK_FileHandle *out;
-
- (void) cls;
- p = GNUNET_DISK_pipe (GNUNET_DISK_PF_NONE);
- if (NULL == p)
- {
- GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR,
- "pipe");
- global_ret = 2;
- return;
- }
- pid = GNUNET_OS_start_process (0,
- p,
- NULL,
- NULL,
- command,
- command,
- "1234",
- "5678",
- NULL);
- if (NULL == pid)
- {
- GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR,
- "fork");
- GNUNET_break (GNUNET_OK ==
- GNUNET_DISK_pipe_close (p));
- global_ret = 1;
- return;
- }
- GNUNET_break (GNUNET_OK ==
- GNUNET_DISK_pipe_close_end (p,
- GNUNET_DISK_PIPE_END_READ));
- out = GNUNET_DISK_pipe_detach_end (p,
- GNUNET_DISK_PIPE_END_WRITE);
- GNUNET_assert (NULL != out);
- GNUNET_break (GNUNET_OK ==
- GNUNET_DISK_pipe_close (p));
-
- GNUNET_SCHEDULER_add_shutdown (&do_shutdown,
- NULL);
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"Alright");
- cwh = ANASTASIS_wait_child (pid,
- &child_completed_callback,
- cls);
- GNUNET_break (NULL != cwh);
- GNUNET_assert (5 ==
- GNUNET_DISK_file_write (out,
- "Hello",
- 5));
- GNUNET_break (GNUNET_OK ==
- GNUNET_DISK_file_close (out));
-}
-
-
-int
-main (int argc,
- const char *const argv[])
-{
- GNUNET_log_setup (argv[0],
- "DEBUG",
- NULL);
- GNUNET_SCHEDULER_run (&test_child_management,
- NULL);
- return global_ret;
-}
-
-
-/* end of test_anastasis_child_management.c */
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [taler-anastasis] branch master updated: child management is now in GNUnet, remove from ANASTASIS,
gnunet <=