cleanup API for get_hello and get_hello_cancel
authorChristian Grothoff <christian@grothoff.org>
Fri, 2 Sep 2011 11:21:00 +0000 (11:21 +0000)
committerChristian Grothoff <christian@grothoff.org>
Fri, 2 Sep 2011 11:21:00 +0000 (11:21 +0000)
20 files changed:
src/core/test_core_api.c
src/core/test_core_api_preferences.c
src/core/test_core_api_reliability.c
src/core/test_core_quota_compliance.c
src/dht/gnunet-service-dht.c
src/hostlist/test_gnunet_daemon_hostlist.c
src/hostlist/test_gnunet_daemon_hostlist_reconnect.c
src/include/gnunet_testing_lib.h
src/include/gnunet_transport_service.h
src/mesh/mesh_api.c
src/nat/test_nat_test.c
src/testing/testing.c
src/transport/Makefile.am
src/transport/gnunet-service-transport.c
src/transport/gnunet-service-transport_validation.c
src/transport/test_quota_compliance.c
src/transport/test_transport_api_disconnect.c
src/transport/transport-testing.c
src/transport/transport-testing.h
src/transport/transport_api.c

index 28805a372546e100d8c9223550b71a9d2ca953fc..894e4f6428a634a35633060a92325171a8232e7d 100644 (file)
@@ -46,6 +46,7 @@ struct PeerContext
   struct GNUNET_CORE_Handle *ch;
   struct GNUNET_PeerIdentity id;
   struct GNUNET_TRANSPORT_Handle *th;
+  struct GNUNET_TRANSPORT_GetHelloHandle *ghh;
   struct GNUNET_MessageHeader *hello;
   int connect_status;
 #if START_ARM
@@ -91,8 +92,8 @@ terminate_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
   GNUNET_assert (ok == 6);
   GNUNET_CORE_disconnect (p1.ch);
   GNUNET_CORE_disconnect (p2.ch);
-  GNUNET_TRANSPORT_get_hello_cancel (p1.th, &process_hello, &p1);
-  GNUNET_TRANSPORT_get_hello_cancel (p2.th, &process_hello, &p2);
+  GNUNET_TRANSPORT_get_hello_cancel (p1.ghh);
+  GNUNET_TRANSPORT_get_hello_cancel (p2.ghh);
   GNUNET_TRANSPORT_disconnect (p1.th);
   GNUNET_TRANSPORT_disconnect (p2.th);
   ok = 0;
@@ -118,13 +119,13 @@ terminate_task_error (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
   }
   if (p1.th != NULL)
   {
-    GNUNET_TRANSPORT_get_hello_cancel (p1.th, &process_hello, &p1);
+    GNUNET_TRANSPORT_get_hello_cancel (p1.ghh);
     GNUNET_TRANSPORT_disconnect (p1.th);
     p1.th = NULL;
   }
   if (p2.th != NULL)
   {
-    GNUNET_TRANSPORT_get_hello_cancel (p2.th, &process_hello, &p2);
+    GNUNET_TRANSPORT_get_hello_cancel (p2.ghh);
     GNUNET_TRANSPORT_disconnect (p2.th);
     p2.th = NULL;
   }
@@ -312,7 +313,7 @@ setup_peer (struct PeerContext *p, const char *cfgname)
   GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname));
   p->th = GNUNET_TRANSPORT_connect (p->cfg, NULL, p, NULL, NULL, NULL);
   GNUNET_assert (p->th != NULL);
-  GNUNET_TRANSPORT_get_hello (p->th, &process_hello, p);
+  p->ghh = GNUNET_TRANSPORT_get_hello (p->th, &process_hello, p);
 }
 
 
index 8bc977df22f2b37acae4905eed4cfa4268900046..d3364463a9b963a3e8e5dc7e9ecb1d7663c0948d 100644 (file)
@@ -43,6 +43,7 @@ struct PeerContext
   struct GNUNET_CORE_Handle *ch;
   struct GNUNET_PeerIdentity id;
   struct GNUNET_TRANSPORT_Handle *th;
+  struct GNUNET_TRANSPORT_GetHelloHandle *ghh;
   struct GNUNET_MessageHeader *hello;
   int connect_status;
 #if START_ARM
@@ -86,8 +87,8 @@ terminate_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
 #endif
   GNUNET_assert (ok == 6);
   GNUNET_assert (NULL == irc);
-  GNUNET_TRANSPORT_get_hello_cancel (p1.th, &process_hello, &p1);
-  GNUNET_TRANSPORT_get_hello_cancel (p2.th, &process_hello, &p2);
+  GNUNET_TRANSPORT_get_hello_cancel (p1.ghh);
+  GNUNET_TRANSPORT_get_hello_cancel (p2.ghh);
   GNUNET_CORE_disconnect (p1.ch);
   GNUNET_CORE_disconnect (p2.ch);
   GNUNET_TRANSPORT_disconnect (p1.th);
@@ -119,8 +120,8 @@ terminate_task_error (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
     GNUNET_SCHEDULER_cancel (ask_task);
     ask_task = GNUNET_SCHEDULER_NO_TASK;
   }
-  GNUNET_TRANSPORT_get_hello_cancel (p1.th, &process_hello, &p1);
-  GNUNET_TRANSPORT_get_hello_cancel (p2.th, &process_hello, &p2);
+  GNUNET_TRANSPORT_get_hello_cancel (p1.ghh);
+  GNUNET_TRANSPORT_get_hello_cancel (p2.ghh);
   GNUNET_CORE_disconnect (p1.ch);
   GNUNET_CORE_disconnect (p2.ch);
   GNUNET_TRANSPORT_disconnect (p1.th);
@@ -425,7 +426,7 @@ setup_peer (struct PeerContext *p, const char *cfgname)
   GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname));
   p->th = GNUNET_TRANSPORT_connect (p->cfg, NULL, p, NULL, NULL, NULL);
   GNUNET_assert (p->th != NULL);
-  GNUNET_TRANSPORT_get_hello (p->th, &process_hello, p);
+  p->ghh = GNUNET_TRANSPORT_get_hello (p->th, &process_hello, p);
 }
 
 
index 47d1ae8ac60995e864667bd2cccc0082b9560c8b..ad6e6a76199182542ade88f5a3ae59b7e0e62885 100644 (file)
@@ -74,6 +74,7 @@ struct PeerContext
   struct GNUNET_PeerIdentity id;
   struct GNUNET_TRANSPORT_Handle *th;
   struct GNUNET_MessageHeader *hello;
+  struct GNUNET_TRANSPORT_GetHelloHandle *ghh;
   int connect_status;
 #if START_ARM
   struct GNUNET_OS_Process *arm_proc;
@@ -121,8 +122,8 @@ terminate_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
 {
   unsigned long long delta;
 
-  GNUNET_TRANSPORT_get_hello_cancel (p1.th, &process_hello, &p1);
-  GNUNET_TRANSPORT_get_hello_cancel (p2.th, &process_hello, &p2);
+  GNUNET_TRANSPORT_get_hello_cancel (p1.ghh);
+  GNUNET_TRANSPORT_get_hello_cancel (p2.ghh);
   GNUNET_CORE_disconnect (p1.ch);
   p1.ch = NULL;
   GNUNET_CORE_disconnect (p2.ch);
@@ -156,13 +157,13 @@ terminate_task_error (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
   }
   if (p1.th != NULL)
   {
-    GNUNET_TRANSPORT_get_hello_cancel (p1.th, &process_hello, &p1);
+    GNUNET_TRANSPORT_get_hello_cancel (p1.ghh);
     GNUNET_TRANSPORT_disconnect (p1.th);
     p1.th = NULL;
   }
   if (p2.th != NULL)
   {
-    GNUNET_TRANSPORT_get_hello_cancel (p2.th, &process_hello, &p2);
+    GNUNET_TRANSPORT_get_hello_cancel (p2.ghh);
     GNUNET_TRANSPORT_disconnect (p2.th);
     p2.th = NULL;
   }
@@ -436,7 +437,7 @@ setup_peer (struct PeerContext *p, const char *cfgname)
   GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname));
   p->th = GNUNET_TRANSPORT_connect (p->cfg, NULL, p, NULL, NULL, NULL);
   GNUNET_assert (p->th != NULL);
-  GNUNET_TRANSPORT_get_hello (p->th, &process_hello, p);
+  p->ghh = GNUNET_TRANSPORT_get_hello (p->th, &process_hello, p);
 }
 
 
index 41d156c6bc2d6fa028990ff0e0e3cd404afa87a9..d955e0fd0677f47de871751a2e328df295f91902 100644 (file)
@@ -81,6 +81,7 @@ struct PeerContext
   struct GNUNET_TRANSPORT_Handle *th;
   struct GNUNET_MessageHeader *hello;
   struct GNUNET_STATISTICS_Handle *stats;
+  struct GNUNET_TRANSPORT_GetHelloHandle *ghh;
   int connect_status;
 #if START_ARM
   struct GNUNET_OS_Process *arm_proc;
@@ -122,8 +123,8 @@ terminate_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
 {
   struct GNUNET_CORE_Handle *ch;
 
-  GNUNET_TRANSPORT_get_hello_cancel (p2.th, &process_hello, &p2);
-  GNUNET_TRANSPORT_get_hello_cancel (p1.th, &process_hello, &p1);
+  GNUNET_TRANSPORT_get_hello_cancel (p2.ghh);
+  GNUNET_TRANSPORT_get_hello_cancel (p1.ghh);
   ch = p1.ch;
   p1.ch = NULL;
   GNUNET_CORE_disconnect (ch);
@@ -147,8 +148,8 @@ terminate_task_error (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
   if (measure_task != GNUNET_SCHEDULER_NO_TASK)
     GNUNET_SCHEDULER_cancel (measure_task);
 
-  GNUNET_TRANSPORT_get_hello_cancel (p1.th, &process_hello, &p1);
-  GNUNET_TRANSPORT_get_hello_cancel (p2.th, &process_hello, &p2);
+  GNUNET_TRANSPORT_get_hello_cancel (p1.ghh);
+  GNUNET_TRANSPORT_get_hello_cancel (p2.ghh);
 
   GNUNET_CORE_disconnect (p1.ch);
   p1.ch = NULL;
@@ -563,7 +564,7 @@ setup_peer (struct PeerContext *p, const char *cfgname)
   GNUNET_assert (p->stats != NULL);
   p->th = GNUNET_TRANSPORT_connect (p->cfg, NULL, p, NULL, NULL, NULL);
   GNUNET_assert (p->th != NULL);
-  GNUNET_TRANSPORT_get_hello (p->th, &process_hello, p);
+  p->ghh = GNUNET_TRANSPORT_get_hello (p->th, &process_hello, p);
 }
 
 
index cbeecb5cc12ac8921a4a9a182e32acbb33ef1974..b864e39e348c2d47765ab3ee3b8802e033d6ce3a 100644 (file)
@@ -782,6 +782,10 @@ static struct GNUNET_DATACACHE_Handle *datacache;
  */
 struct GNUNET_STATISTICS_Handle *stats;
 
+/**
+ * Handle to get our current HELLO.
+ */
+static struct GNUNET_TRANSPORT_GetHelloHandle *ghh;
 
 /**
  * The configuration the DHT service is running with
@@ -5001,11 +5005,16 @@ shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
   int bucket_count;
   struct PeerInfo *pos;
 
+  if (NULL != ghh)
+  {
+    GNUNET_TRANSPORT_get_hello_cancel (ghh);
+    ghh = NULL;
+  }
   if (transport_handle != NULL)
   {
     GNUNET_free_non_null (my_hello);
-    GNUNET_TRANSPORT_get_hello_cancel (transport_handle, &process_hello, NULL);
     GNUNET_TRANSPORT_disconnect (transport_handle);
+    transport_handle = NULL;
   }
   if (coreAPI != NULL)
   {
@@ -5304,7 +5313,7 @@ run (void *cls, struct GNUNET_SERVER_Handle *server,
   transport_handle =
       GNUNET_TRANSPORT_connect (cfg, NULL, NULL, NULL, NULL, NULL);
   if (transport_handle != NULL)
-    GNUNET_TRANSPORT_get_hello (transport_handle, &process_hello, NULL);
+    ghh = GNUNET_TRANSPORT_get_hello (transport_handle, &process_hello, NULL);
   else
     GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
                 "Failed to connect to transport service!\n");
index 909b946e78f70fd1bdf792ccef37819e7ceba5c2..b6d0a17360350cf77cac60ed5b05282a76090eb7 100644 (file)
@@ -46,6 +46,7 @@ struct PeerContext
   struct GNUNET_CONFIGURATION_Handle *cfg;
   struct GNUNET_TRANSPORT_Handle *th;
   struct GNUNET_MessageHeader *hello;
+  struct GNUNET_TRANSPORT_GetHelloHandle *ghh;
 #if START_ARM
   struct GNUNET_OS_Process *arm_proc;
 #endif
@@ -117,7 +118,7 @@ process_hello (void *cls, const struct GNUNET_MessageHeader *message)
 {
   struct PeerContext *p = cls;
 
-  GNUNET_TRANSPORT_get_hello_cancel (p->th, &process_hello, p);
+  GNUNET_TRANSPORT_get_hello_cancel (p->ghh);
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
               "Received HELLO, starting hostlist service.\n");
 }
@@ -140,7 +141,7 @@ setup_peer (struct PeerContext *p, const char *cfgname)
   p->th =
       GNUNET_TRANSPORT_connect (p->cfg, NULL, p, NULL, &notify_connect, NULL);
   GNUNET_assert (p->th != NULL);
-  GNUNET_TRANSPORT_get_hello (p->th, &process_hello, p);
+  p->ghh = GNUNET_TRANSPORT_get_hello (p->th, &process_hello, p);
 }
 
 
index ff625cf8eb9423fb5e15e17f76faca596e15c22c..078c2a54ec86393c3e674917f81a32505cf9e5f6 100644 (file)
@@ -47,6 +47,7 @@ struct PeerContext
   struct GNUNET_CONFIGURATION_Handle *cfg;
   struct GNUNET_TRANSPORT_Handle *th;
   struct GNUNET_MessageHeader *hello;
+  struct GNUNET_TRANSPORT_GetHelloHandle *ghh;
 #if START_ARM
   struct GNUNET_OS_Process *arm_proc;
 #endif
@@ -121,7 +122,7 @@ process_hello (void *cls, const struct GNUNET_MessageHeader *message)
 {
   struct PeerContext *p = cls;
 
-  GNUNET_TRANSPORT_get_hello_cancel (p->th, &process_hello, p);
+  GNUNET_TRANSPORT_get_hello_cancel (p->ghh);
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
               "Received HELLO, starting hostlist service.\n");
 }
@@ -144,7 +145,7 @@ setup_peer (struct PeerContext *p, const char *cfgname)
   p->th =
       GNUNET_TRANSPORT_connect (p->cfg, NULL, p, NULL, &notify_connect, NULL);
   GNUNET_assert (p->th != NULL);
-  GNUNET_TRANSPORT_get_hello (p->th, &process_hello, p);
+  p->ghh = GNUNET_TRANSPORT_get_hello (p->th, &process_hello, p);
 }
 
 
index 786522cddb9e6d1f2e491c676d96665b5eb0a6b7..945a3900b1fbdfad831b1167bc229ad26b635684 100644 (file)
@@ -318,6 +318,11 @@ struct GNUNET_TESTING_Daemon
    */
   struct GNUNET_TRANSPORT_Handle *th;
 
+  /**
+   * Handle for getting HELLOs from transport
+   */
+  struct GNUNET_TRANSPORT_GetHelloHandle *ghh;
+
   /**
    * HELLO message for this peer
    */
@@ -723,7 +728,7 @@ GNUNET_TESTING_daemons_continue_startup (struct GNUNET_TESTING_PeerGroup *pg);
  * @param cb function to call at the end
  * @param cb_cls closure for cb
  */
-struct GNUNET_TESTING_ConnectContext *
+void                            /* struct GNUNET_TESTING_ConnectContext * */
 GNUNET_TESTING_daemons_connect (struct GNUNET_TESTING_Daemon *d1,
                                 struct GNUNET_TESTING_Daemon *d2,
                                 struct GNUNET_TIME_Relative timeout,
@@ -733,6 +738,7 @@ GNUNET_TESTING_daemons_connect (struct GNUNET_TESTING_Daemon *d1,
                                 void *cb_cls);
 
 
+#if 0
 /**
  * Cancel an attempt to connect two daemons.
  *
@@ -741,6 +747,7 @@ GNUNET_TESTING_daemons_connect (struct GNUNET_TESTING_Daemon *d1,
 void
 GNUNET_TESTING_daemons_connect_cancel (struct GNUNET_TESTING_ConnectContext
                                        *cc);
+#endif
 
 
 /**
index e90acab4d2875a7e7d5bdd617c99b7459a3b295b..84a13ed68a45ba418872c4fc8d21eab0e18142d2 100644 (file)
@@ -572,14 +572,21 @@ typedef void (*GNUNET_TRANSPORT_HelloUpdateCallback) (void *cls,
                                                       hello);
 
 
+/**
+ * Handle to cancel a 'GNUNET_TRANSPORT_get_hello' operation.
+ */
+struct GNUNET_TRANSPORT_GetHelloHandle;
+
+
 /**
  * Obtain updates on changes to the HELLO message for this peer.
  *
  * @param handle connection to transport service
  * @param rec function to call with the HELLO
  * @param rec_cls closure for rec
+ * @return handle to cancel the operation, NULL on error
  */
-void
+struct GNUNET_TRANSPORT_GetHelloHandle *
 GNUNET_TRANSPORT_get_hello (struct GNUNET_TRANSPORT_Handle *handle,
                             GNUNET_TRANSPORT_HelloUpdateCallback rec,
                             void *rec_cls);
@@ -588,14 +595,10 @@ GNUNET_TRANSPORT_get_hello (struct GNUNET_TRANSPORT_Handle *handle,
 /**
  * Stop receiving updates about changes to our HELLO message.
  *
- * @param handle connection to transport service
- * @param rec function previously registered to be called with the HELLOs
- * @param rec_cls closure for rec
+ * @param ghh handle returned from 'GNUNET_TRANSPORT_get_hello')
  */
 void
-GNUNET_TRANSPORT_get_hello_cancel (struct GNUNET_TRANSPORT_Handle *handle,
-                                   GNUNET_TRANSPORT_HelloUpdateCallback rec,
-                                   void *rec_cls);
+GNUNET_TRANSPORT_get_hello_cancel (struct GNUNET_TRANSPORT_GetHelloHandle *ghh);
 
 
 /**
index 61559362187cb43993f12f9dd410e0a301bc0109..8476be3969d106f3a2d6ffee92a30fafce1bd1de 100644 (file)
@@ -921,4 +921,4 @@ GNUNET_MESH_disconnect (struct GNUNET_MESH_Handle *handle)
   GNUNET_free (handle);
 }
 
-/* end of mesh_api.c */
\ No newline at end of file
+/* end of mesh_api.c */
index 5a716bd8e5285038ea1688214ad9fe5af092166f..1b4d1bc1d222d35e556e52a172d587ad89e6336e 100644 (file)
@@ -111,18 +111,14 @@ main (int argc, char *const argv[])
   nat_res = GNUNET_OS_check_helper_binary ("gnunet-nat-server");
   if (GNUNET_NO == nat_res)
   {
-    GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
-        "Cannot run NAT test: `%s' %s \n",
-        "gnunet-nat-server",
-         "SUID not set");
+    GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Cannot run NAT test: `%s' %s \n",
+                "gnunet-nat-server", "SUID not set");
     return 0;
   }
-  if (GNUNET_SYSERR ==  nat_res)
+  if (GNUNET_SYSERR == nat_res)
   {
-    GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
-        "Cannot run NAT test: `%s' %s \n",
-        "gnunet-nat-server",
-        "file not found");
+    GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Cannot run NAT test: `%s' %s \n",
+                "gnunet-nat-server", "file not found");
     return 0;
   }
 
index 3a712f0719b7495c1f053e9776368779611bf38d..5eaa0a12b09a43b38411acc1712fc29b3a23fdcb 100644 (file)
@@ -137,9 +137,9 @@ process_hello (void *cls, const struct GNUNET_MessageHeader *message)
   {
     return;
   }
-  if (daemon->th != NULL)
+  if (daemon->ghh != NULL)
   {
-    GNUNET_TRANSPORT_get_hello_cancel (daemon->th, &process_hello, daemon);
+    GNUNET_TRANSPORT_get_hello_cancel (daemon->ghh);
   }
 #if DEBUG_TESTING
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@@ -246,7 +246,7 @@ testing_init (void *cls, struct GNUNET_CORE_Handle *server,
               GNUNET_i2s (my_identity));
 #endif
 
-  GNUNET_TRANSPORT_get_hello (d->th, &process_hello, d);
+  d->ghh = GNUNET_TRANSPORT_get_hello (d->th, &process_hello, d);
   /* wait some more */
   if (d->task != GNUNET_SCHEDULER_NO_TASK)
     GNUNET_SCHEDULER_cancel (d->task);
@@ -706,7 +706,7 @@ start_fsm (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
                 GNUNET_i2s (&d->id));
 #endif
 
-    GNUNET_TRANSPORT_get_hello (d->th, &process_hello, d);
+    d->ghh = GNUNET_TRANSPORT_get_hello (d->th, &process_hello, d);
     GNUNET_SCHEDULER_add_now (&notify_daemon_started, d);
     /*cb = d->cb;
      * d->cb = NULL;
@@ -836,7 +836,8 @@ start_fsm (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
                       ("either `gnunet-arm' or `ssh' does not seem to terminate.\n"));
         if (d->th != NULL)
         {
-          GNUNET_TRANSPORT_get_hello_cancel (d->th, &process_hello, d);
+          GNUNET_TRANSPORT_get_hello_cancel (d->ghh);
+          d->ghh = NULL;
           GNUNET_TRANSPORT_disconnect (d->th);
           d->th = NULL;
         }
@@ -865,7 +866,8 @@ start_fsm (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
                     ("shutdown (either `gnunet-arm' or `ssh') did not complete cleanly.\n"));
       if (d->th != NULL)
       {
-        GNUNET_TRANSPORT_get_hello_cancel (d->th, &process_hello, d);
+        GNUNET_TRANSPORT_get_hello_cancel (d->ghh);
+        d->ghh = NULL;
         GNUNET_TRANSPORT_disconnect (d->th);
         d->th = NULL;
       }
@@ -896,7 +898,8 @@ start_fsm (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
 
     if (d->th != NULL)
     {
-      GNUNET_TRANSPORT_get_hello_cancel (d->th, &process_hello, d);
+      GNUNET_TRANSPORT_get_hello_cancel (d->ghh);
+      d->ghh = NULL;
       GNUNET_TRANSPORT_disconnect (d->th);
       d->th = NULL;
     }
@@ -1473,7 +1476,8 @@ GNUNET_TESTING_daemon_restart (struct GNUNET_TESTING_Daemon *d,
 
   if (d->th != NULL)
   {
-    GNUNET_TRANSPORT_get_hello_cancel (d->th, &process_hello, d);
+    GNUNET_TRANSPORT_get_hello_cancel (d->ghh);
+    d->ghh = NULL;
     GNUNET_TRANSPORT_disconnect (d->th);
     d->th = NULL;
   }
@@ -1715,7 +1719,8 @@ GNUNET_TESTING_daemon_stop (struct GNUNET_TESTING_Daemon *d,
     d->churn = GNUNET_YES;
   if (d->th != NULL)
   {
-    GNUNET_TRANSPORT_get_hello_cancel (d->th, &process_hello, d);
+    GNUNET_TRANSPORT_get_hello_cancel (d->ghh);
+    d->ghh = NULL;
     GNUNET_TRANSPORT_disconnect (d->th);
     d->th = NULL;
   }
@@ -2215,14 +2220,16 @@ reattempt_daemons_connect (void *cls,
     ctx->d2->hello = NULL;
     if (NULL != ctx->d2->th)
     {
-      GNUNET_TRANSPORT_get_hello_cancel (ctx->d2->th, &process_hello, ctx->d2);
+      GNUNET_TRANSPORT_get_hello_cancel (ctx->d2->ghh);
+      ctx->d2->ghh = NULL;
       GNUNET_TRANSPORT_disconnect (ctx->d2->th);
     }
     ctx->d2->th =
         GNUNET_TRANSPORT_connect (ctx->d2->cfg, &ctx->d2->id, NULL, NULL, NULL,
                                   NULL);
     GNUNET_assert (ctx->d2->th != NULL);
-    GNUNET_TRANSPORT_get_hello (ctx->d2->th, &process_hello, ctx->d2);
+    ctx->d2->ghh =
+        GNUNET_TRANSPORT_get_hello (ctx->d2->th, &process_hello, ctx->d2);
   }
 
   if ((NULL == ctx->d2->hello) && (ctx->d2->th == NULL))
@@ -2240,7 +2247,8 @@ reattempt_daemons_connect (void *cls,
                  _("Failed to connect to transport service!\n"));
       return;
     }
-    GNUNET_TRANSPORT_get_hello (ctx->d2->th, &process_hello, ctx->d2);
+    ctx->d2->ghh =
+        GNUNET_TRANSPORT_get_hello (ctx->d2->th, &process_hello, ctx->d2);
   }
 
   if (ctx->send_hello == GNUNET_YES)
@@ -2342,7 +2350,8 @@ core_initial_iteration (void *cls, const struct GNUNET_PeerIdentity *peer,
                    _("Failed to connect to transport service!\n"));
         return;
       }
-      GNUNET_TRANSPORT_get_hello (ctx->d2->th, &process_hello, ctx->d2);
+      ctx->d2->ghh =
+          GNUNET_TRANSPORT_get_hello (ctx->d2->th, &process_hello, ctx->d2);
     }
 
     if (ctx->send_hello == GNUNET_YES)
index bfe717958f1864b40304a0a297b98543bf73fdcc..c9bc8c440441cf6c283c43d75819f158aa40d09e 100644 (file)
@@ -69,7 +69,7 @@ noinst_PROGRAMS = $(WLAN_BIN_DUMMY)
 lib_LTLIBRARIES = \
   libgnunettransport.la \
   libgnunettransporttesting.la
+
 libgnunettransporttesting_la_SOURCES = \
        transport-testing.c
 libgnunettransporttesting_la_LIBADD = \
@@ -355,7 +355,6 @@ test_transport_api_disconnect_LDADD = \
  $(top_builddir)/src/transport/libgnunettransport.la \
  $(top_builddir)/src/hello/libgnunethello.la \
  $(top_builddir)/src/statistics/libgnunetstatistics.la \
- $(top_builddir)/src/testing/libgnunettesting.la \
  $(top_builddir)/src/util/libgnunetutil.la 
 
 test_transport_startonly_SOURCES = \
@@ -364,7 +363,6 @@ test_transport_startonly_LDADD = \
  $(top_builddir)/src/transport/libgnunettransport.la \
  $(top_builddir)/src/hello/libgnunethello.la \
  $(top_builddir)/src/statistics/libgnunetstatistics.la \
- $(top_builddir)/src/testing/libgnunettesting.la \
  $(top_builddir)/src/util/libgnunetutil.la \
  $(top_builddir)/src/transport/libgnunettransporttesting.la 
 
@@ -374,7 +372,6 @@ test_transport_ats_LDADD = -lm \
  -lglpk \
  $(top_builddir)/src/transport/libgnunettransport.la \
  $(top_builddir)/src/statistics/libgnunetstatistics.la \
- $(top_builddir)/src/testing/libgnunettesting.la \
  $(top_builddir)/src/util/libgnunetutil.la 
 
 test_transport_ats_multiple_peers_SOURCES = \
index 5bf3c4c772072fa98495c07046c812565feebf5e..74ff1749c9d7ff82fc09dbb19307f22f8bc0b452 100644 (file)
@@ -1616,7 +1616,8 @@ transmit_send_continuation (void *cls, const struct GNUNET_PeerIdentity *target,
   if (n == NULL)
   {
     GNUNET_log_from (GNUNET_ERROR_TYPE_WARNING, "transmit_send_continuation",
-                     "Neighbour `%s' no longer exists\n", GNUNET_i2s (&mq->neighbour_id));
+                     "Neighbour `%s' no longer exists\n",
+                     GNUNET_i2s (&mq->neighbour_id));
     return;
   }
   if (mq->client != NULL)
index a79803afc951774f292176b158956f200b02a81c..654bf52b8bf9082177c91d3bf30d96ade90f451d 100644 (file)
@@ -218,7 +218,7 @@ struct ValidationEntry
   size_t addrlen;
 
   /**
-   * When passing the address in 'add_valid_peer_address', did we 
+   * When passing the address in 'add_valid_peer_address', did we
    * copy the address to the HELLO yet?
    */
   int copied;
@@ -880,7 +880,7 @@ add_valid_peer_address (void *cls, size_t max, void *buf)
   struct ValidationEntry *ve = cls;
 
   if (GNUNET_YES == ve->copied)
-    return 0; /* terminate */
+    return 0;                   /* terminate */
   ve->copied = GNUNET_YES;
   return GNUNET_HELLO_add_address (ve->transport_name, ve->valid_until,
                                    ve->addr, ve->addrlen, buf, max);
index 71332bf36acb58143f689b3996b8df7509f25aa3..63bd7da028951b40f1c9e0c8e21e90269f3c6298 100644 (file)
@@ -601,8 +601,8 @@ notify_connect (void *cls, const struct GNUNET_PeerIdentity *peer,
       GNUNET_SCHEDULER_cancel (tct);
       tct = GNUNET_SCHEDULER_NO_TASK;
     }
-    GNUNET_TRANSPORT_get_hello_cancel (p2.th, &exchange_hello_last, &p2);
-    GNUNET_TRANSPORT_get_hello_cancel (p1.th, &exchange_hello, &p1);
+    GNUNET_TRANSPORT_get_hello_cancel (p2.ghh);
+    GNUNET_TRANSPORT_get_hello_cancel (p1.ghh);
     if (is_asymmetric_send_constant == GNUNET_YES)
       measure (MEASUREMENT_MIN_QUOTA, MEASUREMENT_MAX_QUOTA);
     else if (is_asymmetric_recv_constant == GNUNET_YES)
@@ -776,8 +776,8 @@ run (void *cls, char *const *args, const char *cfgfile,
 
   GNUNET_assert (p1.th != NULL);
   GNUNET_assert (p2.th != NULL);
-  GNUNET_TRANSPORT_get_hello (p1.th, &exchange_hello, &p1);
-  GNUNET_TRANSPORT_get_hello (p2.th, &exchange_hello_last, &p2);
+  p1.ghh = GNUNET_TRANSPORT_get_hello (p1.th, &exchange_hello, &p1);
+  p2.ghh = GNUNET_TRANSPORT_get_hello (p2.th, &exchange_hello_last, &p2);
   tct = GNUNET_SCHEDULER_add_now (&try_connect, NULL);
 }
 
index 540d3b7290bf4a546b15560563235c60d2405a68..a96a1a152a1ce4b0aa53f133b279ab7e824e1d3f 100644 (file)
@@ -170,8 +170,8 @@ end_badly ()
   }
   else
   {
-    GNUNET_TRANSPORT_get_hello_cancel (p2.th, &exchange_hello_last, &p2);
-    GNUNET_TRANSPORT_get_hello_cancel (p1.th, &exchange_hello, &p1);
+    GNUNET_TRANSPORT_get_hello_cancel (p2.ghh);
+    GNUNET_TRANSPORT_get_hello_cancel (p1.ghh);
   }
 
   GNUNET_TRANSPORT_disconnect (p1.th);
@@ -314,8 +314,8 @@ peers_disconnect (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
 
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Disconnecting from Transport \n");
 
-  GNUNET_TRANSPORT_get_hello_cancel (p2.th, &exchange_hello_last, &p2);
-  GNUNET_TRANSPORT_get_hello_cancel (p1.th, &exchange_hello, &p1);
+  GNUNET_TRANSPORT_get_hello_cancel (p2.ghh);
+  GNUNET_TRANSPORT_get_hello_cancel (p1.ghh);
 
   GNUNET_TRANSPORT_disconnect (p1.th);
   p1.th = NULL;
@@ -358,8 +358,8 @@ peers_connect ()
   GNUNET_assert (p1.th != NULL);
   GNUNET_assert (p2.th != NULL);
 
-  GNUNET_TRANSPORT_get_hello (p1.th, &exchange_hello, &p1);
-  GNUNET_TRANSPORT_get_hello (p2.th, &exchange_hello_last, &p2);
+  p1.ghh = GNUNET_TRANSPORT_get_hello (p1.th, &exchange_hello, &p1);
+  p2.ghh = GNUNET_TRANSPORT_get_hello (p2.th, &exchange_hello_last, &p2);
   tct = GNUNET_SCHEDULER_add_now (&try_connect, NULL);
 }
 
index 02bab07f4fadea8a872ef51242e68eec52753fb1..e604c59610f61256a10d212b93650b4f4f7c0547 100644 (file)
@@ -34,7 +34,6 @@ struct ConnectingContext
   GNUNET_SCHEDULER_TaskIdentifier tct;
   GNUNET_TRANSPORT_TESTING_connect_cb cb;
   void *cb_cls;
-
   struct GNUNET_TRANSPORT_Handle *th_p1;
   struct GNUNET_TRANSPORT_Handle *th_p2;
   int p1_c;
@@ -73,8 +72,8 @@ notify_connect_internal (void *cls, const struct GNUNET_PeerIdentity *peer,
   if ((cc->p2_c == GNUNET_YES) && (cc->p2_c == GNUNET_YES))
   {
     /* clean up */
-    GNUNET_TRANSPORT_get_hello_cancel (cc->th_p2, &exchange_hello_last, cc);
-    GNUNET_TRANSPORT_get_hello_cancel (cc->th_p1, &exchange_hello, cc);
+    GNUNET_TRANSPORT_get_hello_cancel (cc->p1->ghh);
+    GNUNET_TRANSPORT_get_hello_cancel (cc->p2->ghh);
 
     if (cc->tct != GNUNET_SCHEDULER_NO_TASK)
       GNUNET_SCHEDULER_cancel (cc->tct);
@@ -315,8 +314,8 @@ GNUNET_TRANSPORT_TESTING_connect_peers (struct PeerContext *p1,
   GNUNET_assert (cc->th_p1 != NULL);
   GNUNET_assert (cc->th_p2 != NULL);
 
-  GNUNET_TRANSPORT_get_hello (cc->th_p1, &exchange_hello, cc);
-  GNUNET_TRANSPORT_get_hello (cc->th_p2, &exchange_hello_last, cc);
+  p1->ghh = GNUNET_TRANSPORT_get_hello (cc->th_p1, &exchange_hello, cc);
+  p2->ghh = GNUNET_TRANSPORT_get_hello (cc->th_p2, &exchange_hello_last, cc);
 
   cc->tct = GNUNET_SCHEDULER_add_now (&try_connect, cc);
   return cc;
@@ -333,8 +332,8 @@ void GNUNET_TRANSPORT_TESTING_connect_peers_cancel
   struct ConnectingContext *cc = ccr;
 
   /* clean up */
-  GNUNET_TRANSPORT_get_hello_cancel (cc->th_p2, &exchange_hello_last, cc);
-  GNUNET_TRANSPORT_get_hello_cancel (cc->th_p1, &exchange_hello, cc);
+  GNUNET_TRANSPORT_get_hello_cancel (cc->p1->ghh);
+  GNUNET_TRANSPORT_get_hello_cancel (cc->p2->ghh);
 
   if (cc->tct != GNUNET_SCHEDULER_NO_TASK)
     GNUNET_SCHEDULER_cancel (cc->tct);
index 852f060e42f02646ecd508ce4a738b5523d1e3c0..80eae363010e91d76cdfe34aeaaa1086ba6b08b0 100644 (file)
@@ -44,6 +44,8 @@ struct PeerContext
 
   struct GNUNET_TRANSPORT_Handle *th;
 
+  struct GNUNET_TRANSPORT_GetHelloHandle *ghh;
+
   struct GNUNET_PeerIdentity id;
 
   struct GNUNET_OS_Process *arm_proc;
index a6d2fa0ba61b85714808897b39dd60d5fd0cb6f9..bbfe1e63d550bb46551e4b6dc97724857ff049d3 100644 (file)
@@ -150,18 +150,23 @@ struct Neighbour
 /**
  * Linked list of functions to call whenever our HELLO is updated.
  */
-struct HelloWaitList
+struct GNUNET_TRANSPORT_GetHelloHandle
 {
 
   /**
    * This is a doubly linked list.
    */
-  struct HelloWaitList *next;
+  struct GNUNET_TRANSPORT_GetHelloHandle *next;
 
   /**
    * This is a doubly linked list.
    */
-  struct HelloWaitList *prev;
+  struct GNUNET_TRANSPORT_GetHelloHandle *prev;
+
+  /**
+   * Transport handle.
+   */
+  struct GNUNET_TRANSPORT_Handle *handle;
 
   /**
    * Callback to call once we got our HELLO.
@@ -232,12 +237,12 @@ struct GNUNET_TRANSPORT_Handle
   /**
    * Linked list of pending requests for our HELLO.
    */
-  struct HelloWaitList *hwl_head;
+  struct GNUNET_TRANSPORT_GetHelloHandle *hwl_head;
 
   /**
    * Linked list of pending requests for our HELLO.
    */
-  struct HelloWaitList *hwl_tail;
+  struct GNUNET_TRANSPORT_GetHelloHandle *hwl_tail;
 
   /**
    * My configuration.
@@ -397,8 +402,8 @@ demultiplexer (void *cls, const struct GNUNET_MessageHeader *msg)
   const struct InboundMessage *im;
   const struct GNUNET_MessageHeader *imm;
   const struct SendOkMessage *okm;
-  struct HelloWaitList *hwl;
-  struct HelloWaitList *next_hwl;
+  struct GNUNET_TRANSPORT_GetHelloHandle *hwl;
+  struct GNUNET_TRANSPORT_GetHelloHandle *next_hwl;
   struct Neighbour *n;
   struct GNUNET_PeerIdentity me;
   uint16_t size;
@@ -1189,50 +1194,39 @@ GNUNET_TRANSPORT_offer_hello (struct GNUNET_TRANSPORT_Handle *handle,
  *            (handshake with transport service pending/failed).
  *             cost estimate will be 0.
  * @param rec_cls closure for rec
+ * @return handle to cancel the operation, NULL on error
  */
-void
+struct GNUNET_TRANSPORT_GetHelloHandle *
 GNUNET_TRANSPORT_get_hello (struct GNUNET_TRANSPORT_Handle *handle,
                             GNUNET_TRANSPORT_HelloUpdateCallback rec,
                             void *rec_cls)
 {
-  struct HelloWaitList *hwl;
+  struct GNUNET_TRANSPORT_GetHelloHandle *hwl;
 
-  hwl = GNUNET_malloc (sizeof (struct HelloWaitList));
+  if (handle->my_hello == NULL)
+    return NULL;
+  hwl = GNUNET_malloc (sizeof (struct GNUNET_TRANSPORT_GetHelloHandle));
   hwl->rec = rec;
   hwl->rec_cls = rec_cls;
+  hwl->handle = handle;
   GNUNET_CONTAINER_DLL_insert (handle->hwl_head, handle->hwl_tail, hwl);
-  if (handle->my_hello == NULL)
-    return;
   rec (rec_cls, (const struct GNUNET_MessageHeader *) handle->my_hello);
+  return hwl;
 }
 
 
 /**
  * Stop receiving updates about changes to our HELLO message.
  *
- * @param handle connection to transport service
- * @param rec function previously registered to be called with the HELLOs
- * @param rec_cls closure for rec
+ * @param ghh handle to cancel
  */
 void
-GNUNET_TRANSPORT_get_hello_cancel (struct GNUNET_TRANSPORT_Handle *handle,
-                                   GNUNET_TRANSPORT_HelloUpdateCallback rec,
-                                   void *rec_cls)
+GNUNET_TRANSPORT_get_hello_cancel (struct GNUNET_TRANSPORT_GetHelloHandle *ghh)
 {
-  struct HelloWaitList *pos;
+  struct GNUNET_TRANSPORT_Handle *handle = ghh->handle;
 
-  pos = handle->hwl_head;
-  while (pos != NULL)
-  {
-    if ((pos->rec == rec) && (pos->rec_cls == rec_cls))
-      break;
-    pos = pos->next;
-  }
-  GNUNET_break (pos != NULL);
-  if (pos == NULL)
-    return;
-  GNUNET_CONTAINER_DLL_remove (handle->hwl_head, handle->hwl_tail, pos);
-  GNUNET_free (pos);
+  GNUNET_CONTAINER_DLL_remove (handle->hwl_head, handle->hwl_tail, ghh);
+  GNUNET_free (ghh);
 }