gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r16686 - in gnunet/src: core dht hostlist include mesh nat


From: gnunet
Subject: [GNUnet-SVN] r16686 - in gnunet/src: core dht hostlist include mesh nat testing transport
Date: Fri, 2 Sep 2011 13:21:00 +0200

Author: grothoff
Date: 2011-09-02 13:21:00 +0200 (Fri, 02 Sep 2011)
New Revision: 16686

Modified:
   gnunet/src/core/test_core_api.c
   gnunet/src/core/test_core_api_preferences.c
   gnunet/src/core/test_core_api_reliability.c
   gnunet/src/core/test_core_quota_compliance.c
   gnunet/src/dht/gnunet-service-dht.c
   gnunet/src/hostlist/test_gnunet_daemon_hostlist.c
   gnunet/src/hostlist/test_gnunet_daemon_hostlist_reconnect.c
   gnunet/src/include/gnunet_testing_lib.h
   gnunet/src/include/gnunet_transport_service.h
   gnunet/src/mesh/mesh_api.c
   gnunet/src/nat/test_nat_test.c
   gnunet/src/testing/testing.c
   gnunet/src/transport/Makefile.am
   gnunet/src/transport/gnunet-service-transport.c
   gnunet/src/transport/gnunet-service-transport_validation.c
   gnunet/src/transport/test_quota_compliance.c
   gnunet/src/transport/test_transport_api_disconnect.c
   gnunet/src/transport/transport-testing.c
   gnunet/src/transport/transport-testing.h
   gnunet/src/transport/transport_api.c
Log:
cleanup API for get_hello and get_hello_cancel

Modified: gnunet/src/core/test_core_api.c
===================================================================
--- gnunet/src/core/test_core_api.c     2011-09-02 10:49:51 UTC (rev 16685)
+++ gnunet/src/core/test_core_api.c     2011-09-02 11:21:00 UTC (rev 16686)
@@ -46,6 +46,7 @@
   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 @@
   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 @@
   }
   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 @@
   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);
 }
 
 

Modified: gnunet/src/core/test_core_api_preferences.c
===================================================================
--- gnunet/src/core/test_core_api_preferences.c 2011-09-02 10:49:51 UTC (rev 
16685)
+++ gnunet/src/core/test_core_api_preferences.c 2011-09-02 11:21:00 UTC (rev 
16686)
@@ -43,6 +43,7 @@
   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 @@
 #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 @@
     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 @@
   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);
 }
 
 

Modified: gnunet/src/core/test_core_api_reliability.c
===================================================================
--- gnunet/src/core/test_core_api_reliability.c 2011-09-02 10:49:51 UTC (rev 
16685)
+++ gnunet/src/core/test_core_api_reliability.c 2011-09-02 11:21:00 UTC (rev 
16686)
@@ -74,6 +74,7 @@
   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 @@
 {
   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 @@
   }
   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 @@
   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);
 }
 
 

Modified: gnunet/src/core/test_core_quota_compliance.c
===================================================================
--- gnunet/src/core/test_core_quota_compliance.c        2011-09-02 10:49:51 UTC 
(rev 16685)
+++ gnunet/src/core/test_core_quota_compliance.c        2011-09-02 11:21:00 UTC 
(rev 16686)
@@ -81,6 +81,7 @@
   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 @@
 {
   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 @@
   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 @@
   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);
 }
 
 

Modified: gnunet/src/dht/gnunet-service-dht.c
===================================================================
--- gnunet/src/dht/gnunet-service-dht.c 2011-09-02 10:49:51 UTC (rev 16685)
+++ gnunet/src/dht/gnunet-service-dht.c 2011-09-02 11:21:00 UTC (rev 16686)
@@ -782,6 +782,10 @@
  */
 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 @@
   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 @@
   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");

Modified: gnunet/src/hostlist/test_gnunet_daemon_hostlist.c
===================================================================
--- gnunet/src/hostlist/test_gnunet_daemon_hostlist.c   2011-09-02 10:49:51 UTC 
(rev 16685)
+++ gnunet/src/hostlist/test_gnunet_daemon_hostlist.c   2011-09-02 11:21:00 UTC 
(rev 16686)
@@ -46,6 +46,7 @@
   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 @@
 {
   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 @@
   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);
 }
 
 

Modified: gnunet/src/hostlist/test_gnunet_daemon_hostlist_reconnect.c
===================================================================
--- gnunet/src/hostlist/test_gnunet_daemon_hostlist_reconnect.c 2011-09-02 
10:49:51 UTC (rev 16685)
+++ gnunet/src/hostlist/test_gnunet_daemon_hostlist_reconnect.c 2011-09-02 
11:21:00 UTC (rev 16686)
@@ -47,6 +47,7 @@
   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 @@
 {
   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 @@
   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);
 }
 
 

Modified: gnunet/src/include/gnunet_testing_lib.h
===================================================================
--- gnunet/src/include/gnunet_testing_lib.h     2011-09-02 10:49:51 UTC (rev 
16685)
+++ gnunet/src/include/gnunet_testing_lib.h     2011-09-02 11:21:00 UTC (rev 
16686)
@@ -319,6 +319,11 @@
   struct GNUNET_TRANSPORT_Handle *th;
 
   /**
+   * Handle for getting HELLOs from transport
+   */
+  struct GNUNET_TRANSPORT_GetHelloHandle *ghh;
+
+  /**
    * HELLO message for this peer
    */
   struct GNUNET_HELLO_Message *hello;
@@ -723,7 +728,7 @@
  * @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 @@
                                 void *cb_cls);
 
 
+#if 0
 /**
  * Cancel an attempt to connect two daemons.
  *
@@ -741,6 +747,7 @@
 void
 GNUNET_TESTING_daemons_connect_cancel (struct GNUNET_TESTING_ConnectContext
                                        *cc);
+#endif
 
 
 /**

Modified: gnunet/src/include/gnunet_transport_service.h
===================================================================
--- gnunet/src/include/gnunet_transport_service.h       2011-09-02 10:49:51 UTC 
(rev 16685)
+++ gnunet/src/include/gnunet_transport_service.h       2011-09-02 11:21:00 UTC 
(rev 16686)
@@ -573,13 +573,20 @@
 
 
 /**
+ * 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 @@
 /**
  * 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);
 
 
 /**

Modified: gnunet/src/mesh/mesh_api.c
===================================================================
--- gnunet/src/mesh/mesh_api.c  2011-09-02 10:49:51 UTC (rev 16685)
+++ gnunet/src/mesh/mesh_api.c  2011-09-02 11:21:00 UTC (rev 16686)
@@ -921,4 +921,4 @@
   GNUNET_free (handle);
 }
 
-/* end of mesh_api.c */
\ No newline at end of file
+/* end of mesh_api.c */

Modified: gnunet/src/nat/test_nat_test.c
===================================================================
--- gnunet/src/nat/test_nat_test.c      2011-09-02 10:49:51 UTC (rev 16685)
+++ gnunet/src/nat/test_nat_test.c      2011-09-02 11:21:00 UTC (rev 16686)
@@ -111,18 +111,14 @@
   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;
   }
 

Modified: gnunet/src/testing/testing.c
===================================================================
--- gnunet/src/testing/testing.c        2011-09-02 10:49:51 UTC (rev 16685)
+++ gnunet/src/testing/testing.c        2011-09-02 11:21:00 UTC (rev 16686)
@@ -137,9 +137,9 @@
   {
     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 @@
               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 @@
                 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 @@
                       ("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 @@
                     ("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 @@
 
     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 @@
 
   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 @@
     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 @@
     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 @@
                  _("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 @@
                    _("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)

Modified: gnunet/src/transport/Makefile.am
===================================================================
--- gnunet/src/transport/Makefile.am    2011-09-02 10:49:51 UTC (rev 16685)
+++ gnunet/src/transport/Makefile.am    2011-09-02 11:21:00 UTC (rev 16686)
@@ -69,7 +69,7 @@
 lib_LTLIBRARIES = \
   libgnunettransport.la \
   libgnunettransporttesting.la
- 
+
 libgnunettransporttesting_la_SOURCES = \
        transport-testing.c
 libgnunettransporttesting_la_LIBADD = \
@@ -355,7 +355,6 @@
  $(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 @@
  $(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 @@
  -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 = \

Modified: gnunet/src/transport/gnunet-service-transport.c
===================================================================
--- gnunet/src/transport/gnunet-service-transport.c     2011-09-02 10:49:51 UTC 
(rev 16685)
+++ gnunet/src/transport/gnunet-service-transport.c     2011-09-02 11:21:00 UTC 
(rev 16686)
@@ -1616,7 +1616,8 @@
   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)

Modified: gnunet/src/transport/gnunet-service-transport_validation.c
===================================================================
--- gnunet/src/transport/gnunet-service-transport_validation.c  2011-09-02 
10:49:51 UTC (rev 16685)
+++ gnunet/src/transport/gnunet-service-transport_validation.c  2011-09-02 
11:21:00 UTC (rev 16686)
@@ -218,7 +218,7 @@
   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 @@
   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);

Modified: gnunet/src/transport/test_quota_compliance.c
===================================================================
--- gnunet/src/transport/test_quota_compliance.c        2011-09-02 10:49:51 UTC 
(rev 16685)
+++ gnunet/src/transport/test_quota_compliance.c        2011-09-02 11:21:00 UTC 
(rev 16686)
@@ -601,8 +601,8 @@
       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 @@
 
   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);
 }
 

Modified: gnunet/src/transport/test_transport_api_disconnect.c
===================================================================
--- gnunet/src/transport/test_transport_api_disconnect.c        2011-09-02 
10:49:51 UTC (rev 16685)
+++ gnunet/src/transport/test_transport_api_disconnect.c        2011-09-02 
11:21:00 UTC (rev 16686)
@@ -170,8 +170,8 @@
   }
   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 @@
 
   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 @@
   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);
 }
 

Modified: gnunet/src/transport/transport-testing.c
===================================================================
--- gnunet/src/transport/transport-testing.c    2011-09-02 10:49:51 UTC (rev 
16685)
+++ gnunet/src/transport/transport-testing.c    2011-09-02 11:21:00 UTC (rev 
16686)
@@ -34,7 +34,6 @@
   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 @@
   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_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 @@
   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);

Modified: gnunet/src/transport/transport-testing.h
===================================================================
--- gnunet/src/transport/transport-testing.h    2011-09-02 10:49:51 UTC (rev 
16685)
+++ gnunet/src/transport/transport-testing.h    2011-09-02 11:21:00 UTC (rev 
16686)
@@ -44,6 +44,8 @@
 
   struct GNUNET_TRANSPORT_Handle *th;
 
+  struct GNUNET_TRANSPORT_GetHelloHandle *ghh;
+
   struct GNUNET_PeerIdentity id;
 
   struct GNUNET_OS_Process *arm_proc;

Modified: gnunet/src/transport/transport_api.c
===================================================================
--- gnunet/src/transport/transport_api.c        2011-09-02 10:49:51 UTC (rev 
16685)
+++ gnunet/src/transport/transport_api.c        2011-09-02 11:21:00 UTC (rev 
16686)
@@ -150,20 +150,25 @@
 /**
  * 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.
    */
   GNUNET_TRANSPORT_HelloUpdateCallback rec;
@@ -232,12 +237,12 @@
   /**
    * 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 @@
   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 @@
  *            (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);
 }
 
 




reply via email to

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