code clean up
[oweals/gnunet.git] / src / util / test_service.c
index 6148fa2cc56cfe1e448a8b681fa5149f7db81c7b..5a4fe27d03055c390f794ab67881bd6c9b3bf2cb 100644 (file)
@@ -78,6 +78,14 @@ ready (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
                                        GNUNET_NO, &build_msg, client);
 }
 
+static void
+do_stop (void *cls,
+        const struct GNUNET_SCHEDULER_TaskContext *tc)
+{
+  GNUNET_SERVICE_stop (sctx);
+}
+
+
 static void
 recv_cb (void *cls,
          struct GNUNET_SERVER_Client *client,
@@ -85,7 +93,10 @@ recv_cb (void *cls,
 {
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Receiving client message...\n");
   GNUNET_SERVER_receive_done (client, GNUNET_OK);
-  GNUNET_SCHEDULER_shutdown (sched);
+  if (sctx != NULL)
+    GNUNET_SCHEDULER_add_now (sched, &do_stop, NULL);
+  else
+    GNUNET_SCHEDULER_shutdown (sched);
   ok = 0;
 }