diff options
author | Christian Grothoff <christian@grothoff.org> | 2012-04-25 14:54:46 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2012-04-25 14:54:46 +0000 |
commit | 286b8b5dd542ba1e69b632b8967c7cf9651ffe36 (patch) | |
tree | c01ed9bf2d1d7b06d5e5a75fa99ae2a5481b5942 /src/util/test_service.c | |
parent | af7547fbce7e27513d862c0098fbcb5bdfb678b9 (diff) | |
download | gnunet-286b8b5dd542ba1e69b632b8967c7cf9651ffe36.tar.gz gnunet-286b8b5dd542ba1e69b632b8967c7cf9651ffe36.zip |
-handle shutdown better
Diffstat (limited to 'src/util/test_service.c')
-rw-r--r-- | src/util/test_service.c | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/src/util/test_service.c b/src/util/test_service.c index 92aefc63f..f64503ea5 100644 --- a/src/util/test_service.c +++ b/src/util/test_service.c | |||
@@ -49,10 +49,16 @@ static struct GNUNET_CLIENT_Connection *client; | |||
49 | static void | 49 | static void |
50 | do_stop (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | 50 | do_stop (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) |
51 | { | 51 | { |
52 | GNUNET_CLIENT_disconnect (client); | 52 | if (NULL != client) |
53 | client = NULL; | 53 | { |
54 | GNUNET_SERVICE_stop (sctx); | 54 | GNUNET_CLIENT_disconnect (client); |
55 | sctx = NULL; | 55 | client = NULL; |
56 | } | ||
57 | if (NULL != sctx) | ||
58 | { | ||
59 | GNUNET_SERVICE_stop (sctx); | ||
60 | sctx = NULL; | ||
61 | } | ||
56 | } | 62 | } |
57 | 63 | ||
58 | 64 | ||
@@ -99,12 +105,11 @@ static void | |||
99 | recv_cb (void *cls, struct GNUNET_SERVER_Client *sc, | 105 | recv_cb (void *cls, struct GNUNET_SERVER_Client *sc, |
100 | const struct GNUNET_MessageHeader *message) | 106 | const struct GNUNET_MessageHeader *message) |
101 | { | 107 | { |
108 | if (NULL == message) | ||
109 | return; | ||
102 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Receiving client message...\n"); | 110 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Receiving client message...\n"); |
103 | GNUNET_SERVER_receive_done (sc, GNUNET_OK); | 111 | GNUNET_SERVER_receive_done (sc, GNUNET_OK); |
104 | if (sctx != NULL) | 112 | GNUNET_SCHEDULER_add_now (&do_stop, NULL); |
105 | GNUNET_SCHEDULER_add_now (&do_stop, NULL); | ||
106 | else | ||
107 | GNUNET_SCHEDULER_shutdown (); | ||
108 | ok = 0; | 113 | ok = 0; |
109 | } | 114 | } |
110 | 115 | ||