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 | |
parent | 286b8b5dd542ba1e69b632b8967c7cf9651ffe36 (diff) | |
download | gnunet-163277c0e7edb64b599131b143ae29817dc81d68.tar.gz gnunet-163277c0e7edb64b599131b143ae29817dc81d68.zip |
-fixes
Diffstat (limited to 'src')
-rw-r--r-- | src/util/server.c | 15 | ||||
-rw-r--r-- | src/util/service.c | 15 | ||||
-rw-r--r-- | src/util/test_service.c | 9 |
3 files changed, 27 insertions, 12 deletions
diff --git a/src/util/server.c b/src/util/server.c index a730a5481..568380d5d 100644 --- a/src/util/server.c +++ b/src/util/server.c | |||
@@ -554,13 +554,14 @@ GNUNET_SERVER_create (GNUNET_CONNECTION_AccessCheck access, void *access_cls, | |||
554 | while (NULL != serverAddr[i]) | 554 | while (NULL != serverAddr[i]) |
555 | { | 555 | { |
556 | seen = 0; | 556 | seen = 0; |
557 | for (k=0;k<i-1;k++) | 557 | if (i > 0) |
558 | if ( (socklen[k] == socklen[i]) && | 558 | for (k=0;k<i-1;k++) |
559 | (0 == memcmp (serverAddr[k], serverAddr[i], socklen[i])) ) | 559 | if ( (socklen[k] == socklen[i]) && |
560 | { | 560 | (0 == memcmp (serverAddr[k], serverAddr[i], socklen[i])) ) |
561 | seen = 1; | 561 | { |
562 | break; | 562 | seen = 1; |
563 | } | 563 | break; |
564 | } | ||
564 | if (0 != seen) | 565 | if (0 != seen) |
565 | { | 566 | { |
566 | /* duplicate address, skip */ | 567 | /* duplicate address, skip */ |
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); |
diff --git a/src/util/test_service.c b/src/util/test_service.c index f64503ea5..9b43f924d 100644 --- a/src/util/test_service.c +++ b/src/util/test_service.c | |||
@@ -31,7 +31,7 @@ | |||
31 | #include "gnunet_time_lib.h" | 31 | #include "gnunet_time_lib.h" |
32 | 32 | ||
33 | 33 | ||
34 | #define VERBOSE GNUNET_NO | 34 | #define VERBOSE GNUNET_YES |
35 | 35 | ||
36 | #define PORT 12435 | 36 | #define PORT 12435 |
37 | 37 | ||
@@ -59,6 +59,10 @@ do_stop (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
59 | GNUNET_SERVICE_stop (sctx); | 59 | GNUNET_SERVICE_stop (sctx); |
60 | sctx = NULL; | 60 | sctx = NULL; |
61 | } | 61 | } |
62 | else | ||
63 | { | ||
64 | GNUNET_SCHEDULER_shutdown (); | ||
65 | } | ||
62 | } | 66 | } |
63 | 67 | ||
64 | 68 | ||
@@ -70,6 +74,7 @@ build_msg (void *cls, size_t size, void *buf) | |||
70 | if (size < sizeof (struct GNUNET_MessageHeader)) | 74 | if (size < sizeof (struct GNUNET_MessageHeader)) |
71 | { | 75 | { |
72 | /* timeout */ | 76 | /* timeout */ |
77 | GNUNET_break (0); | ||
73 | GNUNET_SCHEDULER_add_now (&do_stop, NULL); | 78 | GNUNET_SCHEDULER_add_now (&do_stop, NULL); |
74 | ok = 1; | 79 | ok = 1; |
75 | return 0; | 80 | return 0; |
@@ -273,7 +278,6 @@ main (int argc, char *argv[]) | |||
273 | NULL); | 278 | NULL); |
274 | ret += check (); | 279 | ret += check (); |
275 | ret += check (); | 280 | ret += check (); |
276 | |||
277 | // FIXME | 281 | // FIXME |
278 | #ifndef MINGW | 282 | #ifndef MINGW |
279 | s = GNUNET_NETWORK_socket_create (PF_INET6, SOCK_STREAM, 0); | 283 | s = GNUNET_NETWORK_socket_create (PF_INET6, SOCK_STREAM, 0); |
@@ -296,7 +300,6 @@ main (int argc, char *argv[]) | |||
296 | ret += check6 (); | 300 | ret += check6 (); |
297 | } | 301 | } |
298 | ret += check_start_stop (); | 302 | ret += check_start_stop (); |
299 | |||
300 | return ret; | 303 | return ret; |
301 | } | 304 | } |
302 | 305 | ||