dhtlog updates
[oweals/gnunet.git] / src / util / test_service.c
index 6148fa2cc56cfe1e448a8b681fa5149f7db81c7b..6c78a4eb9c097b7297423e29897dcb76b4758359 100644 (file)
@@ -4,7 +4,7 @@
 
      GNUnet is free software; you can redistribute it and/or modify
      it under the terms of the GNU General Public License as published
-     by the Free Software Foundation; either version 2, or (at your
+     by the Free Software Foundation; either version 3, or (at your
      option) any later version.
 
      GNUnet is distributed in the hope that it will be useful, but
@@ -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;
 }
 
@@ -218,6 +229,7 @@ start_stop_main (void *cls,
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
               "Starting service using start method\n");
   sctx = GNUNET_SERVICE_start ("test_service", sched, cfg);
+  GNUNET_assert (NULL != sctx);
   runner (cls, sched, GNUNET_SERVICE_get_server (sctx), cfg);
   *ret = 0;
 }