[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r9395 - gnunet/src/arm
From: |
gnunet |
Subject: |
[GNUnet-SVN] r9395 - gnunet/src/arm |
Date: |
Wed, 4 Nov 2009 08:01:05 -0700 |
Author: grothoff
Date: 2009-11-04 08:01:05 -0700 (Wed, 04 Nov 2009)
New Revision: 9395
Modified:
gnunet/src/arm/gnunet-service-arm.c
Log:
clean up for proper shutdown
Modified: gnunet/src/arm/gnunet-service-arm.c
===================================================================
--- gnunet/src/arm/gnunet-service-arm.c 2009-11-04 14:28:05 UTC (rev 9394)
+++ gnunet/src/arm/gnunet-service-arm.c 2009-11-04 15:01:05 UTC (rev 9395)
@@ -152,7 +152,12 @@
*/
static char *prefix_command;
+/**
+ * Are we in shutdown mode?
+ */
+static int in_shutdown;
+
/**
* Background task doing maintenance.
*
@@ -387,6 +392,14 @@
char *binary;
char *config;
struct stat sbuf;
+
+ if (GNUNET_YES == in_shutdown)
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ _("ARM is shutting down, service `%s' not started.\n"),
servicename);
+ signal_result (client, servicename, GNUNET_MESSAGE_TYPE_ARM_IS_DOWN);
+ return;
+ }
sl = find_name (servicename);
if (sl != NULL)
{
@@ -475,7 +488,9 @@
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
_("Preparing to stop `%s'\n"), servicename);
pos = find_name (servicename);
- if ((pos != NULL) && (pos->kill_continuation != NULL))
+ if ( (pos != NULL) &&
+ ( (pos->kill_continuation != NULL) ||
+ (GNUNET_YES == in_shutdown) ) )
{
/* killing already in progress */
#if DEBUG_ARM
@@ -520,6 +535,8 @@
}
else
{
+ if (GNUNET_YES == in_shutdown)
+ return;
#if DEBUG_ARM
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Sending termination request to service `%s'.\n",
@@ -625,28 +642,27 @@
if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN))
{
GNUNET_log (GNUNET_ERROR_TYPE_INFO, _("Stopping all services\n"));
+ in_shutdown = GNUNET_YES;
pos = running;
while (NULL != pos)
{
- if (0 != PLIBC_KILL (pos->pid, SIGTERM))
- GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill");
+ if ( (pos->pid != 0) &&
+ (0 != PLIBC_KILL (pos->pid, SIGTERM)) )
+ GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill");
pos = pos->next;
}
- while (NULL != (pos = running))
- {
- running = pos->next;
- if (GNUNET_OK != GNUNET_OS_process_wait(pos->pid))
- GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "waitpid");
- if (NULL != pos->kill_continuation)
- pos->kill_continuation (pos->kill_continuation_cls, pos);
- else
- free_entry (pos);
- }
- return;
}
if (cls == NULL)
- GNUNET_SCHEDULER_add_delayed (tc->sched,
- MAINT_FREQUENCY, &maint, NULL);
+ {
+ if ( (in_shutdown == GNUNET_YES) &&
+ (running == NULL) )
+ return; /* we are done! */
+ GNUNET_SCHEDULER_add_delayed (tc->sched,
+ (in_shutdown == GNUNET_YES)
+ ? MAINT_FAST_FREQUENCY
+ : MAINT_FREQUENCY,
+ &maint, NULL);
+ }
/* check for services that died (WAITPID) */
prev = NULL;
@@ -694,18 +710,24 @@
statstr = _( /* process termination method */ "unknown");
statcode = 0;
}
- if (NULL != pos->kill_continuation)
+ if ( (NULL != pos->kill_continuation) ||
+ ( (GNUNET_YES == in_shutdown) &&
+ (pos->pid == 0) ) )
{
if (prev == NULL)
running = next;
else
prev->next = next;
- pos->kill_continuation (pos->kill_continuation_cls, pos);
+ if (NULL != pos->kill_continuation)
+ pos->kill_continuation (pos->kill_continuation_cls, pos);
+ else
+ free_entry (pos);
continue;
}
- GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
- _("Service `%s' terminated with status %s/%d, will try to
restart it!\n"),
- pos->name, statstr, statcode);
+ if (GNUNET_YES != in_shutdown)
+ GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+ _("Service `%s' terminated with status %s/%d, will try to
restart it!\n"),
+ pos->name, statstr, statcode);
/* schedule restart */
pos->pid = 0;
prev = pos;
@@ -723,7 +745,8 @@
if (0 != PLIBC_KILL (pos->pid, SIGTERM))
GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill");
}
- if (pos->pid == 0)
+ if ( (pos->pid == 0) &&
+ (GNUNET_YES != in_shutdown) )
{
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
_("Restarting service `%s'.\n"), pos->name);
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r9395 - gnunet/src/arm,
gnunet <=