gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r16150 - gnunet/src/nse


From: gnunet
Subject: [GNUnet-SVN] r16150 - gnunet/src/nse
Date: Sat, 23 Jul 2011 16:27:40 +0200

Author: grothoff
Date: 2011-07-23 16:27:40 +0200 (Sat, 23 Jul 2011)
New Revision: 16150

Modified:
   gnunet/src/nse/gnunet-service-nse.c
   gnunet/src/nse/test_nse_api.c
Log:
fix shutdown

Modified: gnunet/src/nse/gnunet-service-nse.c
===================================================================
--- gnunet/src/nse/gnunet-service-nse.c 2011-07-23 14:19:09 UTC (rev 16149)
+++ gnunet/src/nse/gnunet-service-nse.c 2011-07-23 14:27:40 UTC (rev 16150)
@@ -40,16 +40,12 @@
  * - handle messages for future round (one into the future, see FIXME)
  */
 #include "platform.h"
-#include "gnunet_client_lib.h"
+#include "gnunet_util_lib.h"
 #include "gnunet_constants.h"
-#include "gnunet_container_lib.h"
 #include "gnunet_protocols.h"
 #include "gnunet_signatures.h"
-#include "gnunet_service_lib.h"
-#include "gnunet_server_lib.h"
 #include "gnunet_statistics_service.h"
 #include "gnunet_core_service.h"
-#include "gnunet_time_lib.h"
 #include "gnunet_nse_service.h"
 #include "nse.h"
 
@@ -992,8 +988,11 @@
       GNUNET_SCHEDULER_cancel (flood_task);
       flood_task = GNUNET_SCHEDULER_NO_TASK;
     }
-  GNUNET_SERVER_notification_context_destroy (nc);
-  nc = NULL;
+  if (nc != NULL)
+    {
+      GNUNET_SERVER_notification_context_destroy (nc);
+      nc = NULL;
+    }
   if (coreAPI != NULL)
     {
       GNUNET_CORE_disconnect (coreAPI);
@@ -1004,6 +1003,11 @@
       GNUNET_STATISTICS_destroy (stats, GNUNET_NO);
       stats = NULL;
     }
+  if (peers != NULL)
+    {
+      GNUNET_CONTAINER_multihashmap_destroy (peers);
+      peers = NULL;
+    }
 }
 
 
@@ -1016,9 +1020,9 @@
  * @param publicKey the public key of this peer
  */
 void
-core_init(void *cls, struct GNUNET_CORE_Handle *server,
-          const struct GNUNET_PeerIdentity *identity,
-          const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *publicKey)
+core_init (void *cls, struct GNUNET_CORE_Handle *server,
+          const struct GNUNET_PeerIdentity *identity,
+          const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *publicKey)
 {
   struct GNUNET_TIME_Absolute now;
   struct GNUNET_TIME_Absolute prev_time;
@@ -1030,7 +1034,7 @@
       GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 
                  "Connection to core FAILED!\n");
 #endif
-      GNUNET_SCHEDULER_add_now (&shutdown_task, NULL);
+      GNUNET_SCHEDULER_shutdown ();
       return;
     }
   my_identity = *identity;
@@ -1096,6 +1100,7 @@
       GNUNET_SCHEDULER_shutdown ();
       return;
     }
+  peers = GNUNET_CONTAINER_multihashmap_create (128);
   GNUNET_SERVER_add_handlers (server, handlers);
   nc = GNUNET_SERVER_notification_context_create (server, 1);
   /* Connect to core service and register core handlers */
@@ -1111,9 +1116,11 @@
                                 NULL, /* Don't want notified about all 
outbound messages */
                                 GNUNET_NO, /* For header only outbound 
notification */
                                 core_handlers); /* Register these handlers */
+  GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL,
+                               &shutdown_task, NULL);
   if (coreAPI == NULL)
     {
-      GNUNET_SCHEDULER_add_now (&shutdown_task, NULL);
+      GNUNET_SCHEDULER_shutdown ();
       return;
     }
   stats = GNUNET_STATISTICS_create ("NSE", cfg);

Modified: gnunet/src/nse/test_nse_api.c
===================================================================
--- gnunet/src/nse/test_nse_api.c       2011-07-23 14:19:09 UTC (rev 16149)
+++ gnunet/src/nse/test_nse_api.c       2011-07-23 14:27:40 UTC (rev 16150)
@@ -47,14 +47,29 @@
 
 static struct PeerContext p1;
 
+
+static void
+stop_arm (struct PeerContext *p)
+{
+#if START_ARM
+  if (0 != GNUNET_OS_process_kill (p->arm_proc, SIGTERM))
+    GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill");
+  GNUNET_OS_process_wait (p->arm_proc);
+  GNUNET_OS_process_close (p->arm_proc);
+  p->arm_proc = NULL;
+#endif
+  GNUNET_CONFIGURATION_destroy (p->cfg);
+}
+
 /**
  * Signature of the main function of a task.
  *
  * @param cls closure
  * @param tc context information (why was this task triggered now)
  */
-static void end_test (void *cls,
-                      const struct GNUNET_SCHEDULER_TaskContext * tc)
+static void
+end_test (void *cls,
+         const struct GNUNET_SCHEDULER_TaskContext * tc)
 {
   if (h != NULL)
     {
@@ -78,11 +93,10 @@
 {
   int *ok = cls;
 
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-              "Received NSE message, estimate %f, standard deviation %f.\n");
+  fprintf (stderr,
+          "Received NSE message, estimate %f, standard deviation %f.\n");
   /* Fantastic check below. Expect NaN, the only thing not equal to itself. */
-  if ((estimate != estimate) && (std_dev != std_dev))
-    (*ok) = 0;
+  (*ok) = 0;
   if (die_task != GNUNET_SCHEDULER_NO_TASK)
     GNUNET_SCHEDULER_cancel(die_task);
   die_task = GNUNET_SCHEDULER_add_now(&end_test, NULL);
@@ -106,18 +120,6 @@
 
 }
 
-static void
-stop_arm (struct PeerContext *p)
-{
-#if START_ARM
-  if (0 != GNUNET_OS_process_kill (p->arm_proc, SIGTERM))
-    GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill");
-  GNUNET_OS_process_wait (p->arm_proc);
-  GNUNET_OS_process_close (p->arm_proc);
-  p->arm_proc = NULL;
-#endif
-  GNUNET_CONFIGURATION_destroy (p->cfg);
-}
 
 
 static void




reply via email to

[Prev in Thread] Current Thread [Next in Thread]