aboutsummaryrefslogtreecommitdiff
path: root/src/arm/gnunet-service-arm.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/arm/gnunet-service-arm.c')
-rw-r--r--src/arm/gnunet-service-arm.c87
1 files changed, 54 insertions, 33 deletions
diff --git a/src/arm/gnunet-service-arm.c b/src/arm/gnunet-service-arm.c
index 3a93c654b..66df86e45 100644
--- a/src/arm/gnunet-service-arm.c
+++ b/src/arm/gnunet-service-arm.c
@@ -396,7 +396,6 @@ free_and_signal (void *cls, struct ServiceList *pos)
396{ 396{
397 struct GNUNET_SERVER_Client *client = cls; 397 struct GNUNET_SERVER_Client *client = cls;
398 /* find_name will remove "pos" from the list! */ 398 /* find_name will remove "pos" from the list! */
399 GNUNET_assert (pos == find_name (pos->name));
400 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Service `%s' stopped\n", pos->name); 399 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Service `%s' stopped\n", pos->name);
401 signal_result (client, pos->name, GNUNET_MESSAGE_TYPE_ARM_IS_DOWN); 400 signal_result (client, pos->name, GNUNET_MESSAGE_TYPE_ARM_IS_DOWN);
402 GNUNET_SERVER_receive_done (client, GNUNET_OK); 401 GNUNET_SERVER_receive_done (client, GNUNET_OK);
@@ -526,6 +525,8 @@ static void
526maint (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 525maint (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
527{ 526{
528 struct ServiceList *pos; 527 struct ServiceList *pos;
528 struct ServiceList *prev;
529 struct ServiceList *next;
529 const char *statstr; 530 const char *statstr;
530 int statcode; 531 int statcode;
531 struct stat sbuf; 532 struct stat sbuf;
@@ -552,45 +553,66 @@ maint (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
552 MAINT_FREQUENCY, &maint, cfg); 553 MAINT_FREQUENCY, &maint, cfg);
553 554
554 /* check for services that died (WAITPID) */ 555 /* check for services that died (WAITPID) */
555 for (pos = running; pos != NULL; pos = pos->next) 556 prev = NULL;
557 next = running;
558 while (NULL != (pos = next))
556 { 559 {
557 enum GNUNET_OS_ProcessStatusType statusType; 560 enum GNUNET_OS_ProcessStatusType statusType;
558 unsigned long statusCode; 561 unsigned long statusCode;
559 562
560 if (GNUNET_SYSERR == (ret = GNUNET_OS_process_status(pos->pid, &statusType, &statusCode))) 563 next = pos->next;
561 continue; 564 if (pos->pid == 0)
562 if ( (ret == GNUNET_NO) || 565 {
563 (statusType == GNUNET_OS_PROCESS_STOPPED) || 566 if (NULL != pos->kill_continuation)
564 (statusType == GNUNET_OS_PROCESS_RUNNING) ) 567 {
565 continue; 568 if (prev == NULL)
569 running = next;
570 else
571 prev->next = next;
572 pos->kill_continuation (pos->kill_continuation_cls, pos);
573 }
574 continue;
575 }
576 if ( (GNUNET_SYSERR == (ret = GNUNET_OS_process_status(pos->pid,
577 &statusType,
578 &statusCode))) ||
579 ( (ret == GNUNET_NO) ||
580 (statusType == GNUNET_OS_PROCESS_STOPPED) ||
581 (statusType == GNUNET_OS_PROCESS_RUNNING) ) )
582 {
583 prev = pos;
584 continue;
585 }
566 if (statusType == GNUNET_OS_PROCESS_EXITED) 586 if (statusType == GNUNET_OS_PROCESS_EXITED)
567 { 587 {
568 statstr = _( /* process termination method */ "exit"); 588 statstr = _( /* process termination method */ "exit");
569 statcode = statusCode; 589 statcode = statusCode;
570 } 590 }
571 else if (statusType == GNUNET_OS_PROCESS_SIGNALED) 591 else if (statusType == GNUNET_OS_PROCESS_SIGNALED)
572 { 592 {
573 statstr = _( /* process termination method */ "signal"); 593 statstr = _( /* process termination method */ "signal");
574 statcode = statusCode; 594 statcode = statusCode;
575 } 595 }
576 else 596 else
577 { 597 {
578 statstr = _( /* process termination method */ "unknown"); 598 statstr = _( /* process termination method */ "unknown");
579 statcode = 0; 599 statcode = 0;
580 } 600 }
581 if (NULL != pos->kill_continuation) 601 if (NULL != pos->kill_continuation)
582 { 602 {
583 pos->kill_continuation (pos->kill_continuation_cls, pos); 603 if (prev == NULL)
584 } 604 running = next;
585 else 605 else
586 { 606 prev->next = next;
587 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 607 pos->kill_continuation (pos->kill_continuation_cls, pos);
588 _ 608 continue;
589 ("Service `%s' terminated with status %s/%d, will try to restart it!\n"),
590 pos->name, statstr, statcode);
591 /* schedule restart */
592 pos->pid = 0;
593 } 609 }
610 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
611 _("Service `%s' terminated with status %s/%d, will try to restart it!\n"),
612 pos->name, statstr, statcode);
613 /* schedule restart */
614 pos->pid = 0;
615 prev = pos;
594 } 616 }
595 617
596 /* check for services that need to be restarted due to 618 /* check for services that need to be restarted due to
@@ -601,8 +623,7 @@ maint (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
601 if ((0 == STAT (pos->config, &sbuf)) && (pos->mtime < sbuf.st_mtime)) 623 if ((0 == STAT (pos->config, &sbuf)) && (pos->mtime < sbuf.st_mtime))
602 { 624 {
603 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 625 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
604 _ 626 _("Restarting service `%s' due to configuration file change.\n"));
605 ("Restarting service `%s' due to configuration file change.\n"));
606 if (0 != PLIBC_KILL (pos->pid, SIGTERM)) 627 if (0 != PLIBC_KILL (pos->pid, SIGTERM))
607 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill"); 628 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill");
608 } 629 }