-starting with service_new main logic
authorChristian Grothoff <christian@grothoff.org>
Mon, 29 Aug 2016 11:58:01 +0000 (11:58 +0000)
committerChristian Grothoff <christian@grothoff.org>
Mon, 29 Aug 2016 11:58:01 +0000 (11:58 +0000)
src/util/service_new.c

index 68988069fa6860b4a90445cfc85c48e186ede745..5817e9eb65e3c17205ee53002b3b0353fadaf84b 100644 (file)
@@ -112,7 +112,7 @@ struct GNUNET_SERVICE_Handle
   /**
    * Message handlers to use for all clients.
    */
-  struct GNUNET_MQ_MessageHandler *handlers;
+  const struct GNUNET_MQ_MessageHandler *handlers;
 
   /**
    * Closure for @e task.
@@ -209,6 +209,20 @@ struct GNUNET_SERVICE_Client
 };
 
 
+static void
+service_main (void *cls)
+{
+  struct GNUNET_SERVICE_Handle *sh = cls;
+
+  GNUNET_SCHEDULER_add_shutdown (&service_shutdown,
+                                 sh);
+  GNUNET_SERVICE_resume (sh);
+  sh->service_init_cb (sh->cb_cls,
+                       sh->cfg,
+                       sh);
+}
+
+
 /**
  * Creates the "main" function for a GNUnet service.  You
  * should almost always use the #GNUNET_SERVICE_MAIN macro
@@ -261,7 +275,12 @@ GNUNET_SERVICE_ruN_ (int argc,
                      void *cls,
                      const struct GNUNET_MQ_MessageHandler *handlers)
 {
-  GNUNET_break (0); // not implemented
+  struct GNUNET_SERVICE_Handle sh;
+
+  // FIXME: setup (parse command line, configuration, init sh)
+  GNUNET_SCHEDULER_run (&service_main,
+                        &sh);
+  // FIXME: cleanup
   return 1;
 }