[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r28618 - msh/src
From: |
gnunet |
Subject: |
[GNUnet-SVN] r28618 - msh/src |
Date: |
Wed, 14 Aug 2013 14:10:38 +0200 |
Author: harsha
Date: 2013-08-14 14:10:38 +0200 (Wed, 14 Aug 2013)
New Revision: 28618
Modified:
msh/src/mshd-server.c
Log:
- handle SIGCHLD
Modified: msh/src/mshd-server.c
===================================================================
--- msh/src/mshd-server.c 2013-08-14 12:04:59 UTC (rev 28617)
+++ msh/src/mshd-server.c 2013-08-14 12:10:38 UTC (rev 28618)
@@ -201,6 +201,10 @@
GNUNET_free (ctx->args[cnt]);
GNUNET_free (ctx->args);
}
+ if (NULL != ctx->proc)
+ {
+ GNUNET_OS_process_destroy (ctx->proc); /* we leave the processes running */
+ }
GNUNET_DISK_file_close (ctx->fin);
GNUNET_DISK_file_close (ctx->fout);
if (GNUNET_SCHEDULER_NO_TASK != ctx->timeout_task)
@@ -224,6 +228,7 @@
struct MessageQueue *mq;
GNUNET_SERVER_client_drop (ctx->client);
+ GNUNET_SERVER_client_disconnect (ctx->client);
if (NULL != ctx->tx)
GNUNET_SERVER_notify_transmit_ready_cancel (ctx->tx);
while (NULL != (mq = ctx->mq_head))
@@ -303,7 +308,6 @@
GNUNET_assert (!(ctx->suspended && suspended));
if (GNUNET_YES == suspended)
ctx->suspended = GNUNET_YES;
- GNUNET_SERVER_client_keep (client);
mq = GNUNET_malloc (sizeof (struct MessageQueue));
mq->msg = msg;
GNUNET_CONTAINER_DLL_insert_tail (ctx->mq_head, ctx->mq_tail, mq);
@@ -512,8 +516,9 @@
if (NULL == client) /* Server shutting down */
return;
- ctx = GNUNET_malloc (sizeof (struct ClientCtx ));
- ctx->client = client;
+ GNUNET_SERVER_client_keep (client);
+ ctx = GNUNET_malloc (sizeof (struct ClientCtx ));
+ ctx->client = client;
GNUNET_SERVER_client_set_user_context (client, ctx);
}
@@ -682,6 +687,28 @@
/**
+ * Callback that will be called when a child processes terminates. The
+ * associated client context for the client which requested this process will
be
+ * destroyed
+ *
+ * @param cls the closure passed to MSH_monitor_process()
+ * @param type the process status type
+ * @param long the return/exit code of the process
+ */
+static void
+proc_exit_cb (void *cls, enum GNUNET_OS_ProcessStatusType type, int code)
+{
+ struct ClientCtx *ctx = cls;
+ struct ExecCtx *exec_ctx = ctx->exec_ctx;
+
+ LOG_DEBUG ("Command `%s' exited.\n", exec_ctx->args[0]);
+ GNUNET_OS_process_destroy (exec_ctx->proc);
+ exec_ctx->proc = NULL;
+ destroy_client_ctx (ctx);
+}
+
+
+/**
* start the process from the execution process
*
* @param ctx the execution context
@@ -704,6 +731,7 @@
ctx->args);
if (NULL == ctx->proc)
return GNUNET_SYSERR;
+ MSH_monitor_process (ctx->proc, &proc_exit_cb, ctx->client_ctx);
ctx->fin = GNUNET_DISK_pipe_detach_end (pin, GNUNET_DISK_PIPE_END_WRITE);
ctx->fout = GNUNET_DISK_pipe_detach_end (pout, GNUNET_DISK_PIPE_END_READ);
GNUNET_assert ((NULL != ctx->fin && (NULL != ctx->fout)));
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r28618 - msh/src,
gnunet <=