diff options
author | Christian Grothoff <christian@grothoff.org> | 2012-04-25 15:21:53 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2012-04-25 15:21:53 +0000 |
commit | 163277c0e7edb64b599131b143ae29817dc81d68 (patch) | |
tree | bc9a67ad3beb6987b5441ab7a29c6da8bb9c5da6 /src/util/service.c | |
parent | 286b8b5dd542ba1e69b632b8967c7cf9651ffe36 (diff) | |
download | gnunet-163277c0e7edb64b599131b143ae29817dc81d68.tar.gz gnunet-163277c0e7edb64b599131b143ae29817dc81d68.zip |
-fixes
Diffstat (limited to 'src/util/service.c')
-rw-r--r-- | src/util/service.c | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/src/util/service.c b/src/util/service.c index fb9830419..ef060daaa 100644 --- a/src/util/service.c +++ b/src/util/service.c | |||
@@ -487,6 +487,11 @@ struct GNUNET_SERVICE_Context | |||
487 | struct GNUNET_NETWORK_Handle **lsocks; | 487 | struct GNUNET_NETWORK_Handle **lsocks; |
488 | 488 | ||
489 | /** | 489 | /** |
490 | * Task ID of the shutdown task. | ||
491 | */ | ||
492 | GNUNET_SCHEDULER_TaskIdentifier shutdown_task; | ||
493 | |||
494 | /** | ||
490 | * Idle timeout for server. | 495 | * Idle timeout for server. |
491 | */ | 496 | */ |
492 | struct GNUNET_TIME_Relative timeout; | 497 | struct GNUNET_TIME_Relative timeout; |
@@ -1454,6 +1459,7 @@ shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
1454 | struct GNUNET_SERVICE_Context *service = cls; | 1459 | struct GNUNET_SERVICE_Context *service = cls; |
1455 | struct GNUNET_SERVER_Handle *server = service->server; | 1460 | struct GNUNET_SERVER_Handle *server = service->server; |
1456 | 1461 | ||
1462 | service->shutdown_task = GNUNET_SCHEDULER_NO_TASK; | ||
1457 | if (0 != (service->options & GNUNET_SERVICE_OPTION_SOFT_SHUTDOWN)) | 1463 | if (0 != (service->options & GNUNET_SERVICE_OPTION_SOFT_SHUTDOWN)) |
1458 | GNUNET_SERVER_stop_listening (server); | 1464 | GNUNET_SERVER_stop_listening (server); |
1459 | else | 1465 | else |
@@ -1501,8 +1507,8 @@ service_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
1501 | { | 1507 | { |
1502 | /* install a task that will kill the server | 1508 | /* install a task that will kill the server |
1503 | * process if the scheduler ever gets a shutdown signal */ | 1509 | * process if the scheduler ever gets a shutdown signal */ |
1504 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, &shutdown_task, | 1510 | sctx->shutdown_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, &shutdown_task, |
1505 | sctx); | 1511 | sctx); |
1506 | } | 1512 | } |
1507 | sctx->my_handlers = GNUNET_malloc (sizeof (defhandlers)); | 1513 | sctx->my_handlers = GNUNET_malloc (sizeof (defhandlers)); |
1508 | memcpy (sctx->my_handlers, defhandlers, sizeof (defhandlers)); | 1514 | memcpy (sctx->my_handlers, defhandlers, sizeof (defhandlers)); |
@@ -1876,6 +1882,11 @@ GNUNET_SERVICE_stop (struct GNUNET_SERVICE_Context *sctx) | |||
1876 | { | 1882 | { |
1877 | unsigned int i; | 1883 | unsigned int i; |
1878 | 1884 | ||
1885 | if (GNUNET_SCHEDULER_NO_TASK != sctx->shutdown_task) | ||
1886 | { | ||
1887 | GNUNET_SCHEDULER_cancel (sctx->shutdown_task); | ||
1888 | sctx->shutdown_task = GNUNET_SCHEDULER_NO_TASK; | ||
1889 | } | ||
1879 | if (NULL != sctx->server) | 1890 | if (NULL != sctx->server) |
1880 | GNUNET_SERVER_destroy (sctx->server); | 1891 | GNUNET_SERVER_destroy (sctx->server); |
1881 | GNUNET_free_non_null (sctx->my_handlers); | 1892 | GNUNET_free_non_null (sctx->my_handlers); |