gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r23656 - in gnunet/src: include testbed


From: gnunet
Subject: [GNUnet-SVN] r23656 - in gnunet/src: include testbed
Date: Wed, 5 Sep 2012 13:44:56 +0200

Author: harsha
Date: 2012-09-05 13:44:56 +0200 (Wed, 05 Sep 2012)
New Revision: 23656

Modified:
   gnunet/src/include/gnunet_testbed_service.h
   gnunet/src/testbed/test_testbed_api.c
   gnunet/src/testbed/testbed_api_services.c
Log:
service connect callback instead of operation completion callback

Modified: gnunet/src/include/gnunet_testbed_service.h
===================================================================
--- gnunet/src/include/gnunet_testbed_service.h 2012-09-05 10:50:56 UTC (rev 
23655)
+++ gnunet/src/include/gnunet_testbed_service.h 2012-09-05 11:44:56 UTC (rev 
23656)
@@ -1041,6 +1041,25 @@
 
 
 /**
+ * Callback to be called when a service connect operation is completed
+ *
+ * @param cls the callback closure from functions generating an operation
+ * @param op the operation that has been finished
+ * @param ca_result the service handle returned from 
GNUNET_TESTBED_ConnectAdapter()
+ * @param emsg error message in case the operation has failed; will be NULL if
+ *          operation has executed successfully.
+ */
+typedef void (*GNUNET_TESTBED_ServiceConnectCompletionCallback) (void *cls,
+                                                                struct
+                                                                
GNUNET_TESTBED_Operation
+                                                                *op,
+                                                                void
+                                                                *ca_result, 
+                                                                const char
+                                                                *emsg );
+
+
+/**
  * Connect to a service offered by the given peer.  Will ensure that
  * the request is queued to not overwhelm our ability to create and
  * maintain connections with other systems.  The actual service
@@ -1065,7 +1084,7 @@
 GNUNET_TESTBED_service_connect (void *op_cls,
                                struct GNUNET_TESTBED_Peer *peer,
                                const char *service_name,
-                                GNUNET_TESTBED_OperationCompletionCallback cb,
+                                
GNUNET_TESTBED_ServiceConnectCompletionCallback cb,
                                 void *cb_cls,
                                GNUNET_TESTBED_ConnectAdapter ca,
                                GNUNET_TESTBED_DisconnectAdapter da,

Modified: gnunet/src/testbed/test_testbed_api.c
===================================================================
--- gnunet/src/testbed/test_testbed_api.c       2012-09-05 10:50:56 UTC (rev 
23655)
+++ gnunet/src/testbed/test_testbed_api.c       2012-09-05 11:44:56 UTC (rev 
23656)
@@ -198,8 +198,10 @@
 static void
 dht_disconnect_adapter (void *cls, void *op_result)
 {
-  if (NULL != op_result)
-    GNUNET_DHT_disconnect (op_result);
+  GNUNET_assert (NULL != op_result);
+  GNUNET_assert (op_result == dht_handle);
+  GNUNET_DHT_disconnect (dht_handle);
+  dht_handle = NULL;
   GNUNET_assert (PEER_SERVICE_CONNECT == sub_test);
   GNUNET_assert (NULL != operation);
   operation = GNUNET_TESTBED_peer_stop (peer);
@@ -208,15 +210,17 @@
 
 
 /**
- * Callback to be called when an operation is completed
+ * Callback to be called when a service connect operation is completed
  *
  * @param cls the callback closure from functions generating an operation
  * @param op the operation that has been finished
+ * @param ca_result the service handle returned from 
GNUNET_TESTBED_ConnectAdapter()
  * @param emsg error message in case the operation has failed; will be NULL if
  *          operation has executed successfully.
  */
 static void 
-op_comp_cb (void *cls, struct GNUNET_TESTBED_Operation *op, const char *emsg)
+service_connect_comp_cb (void *cls, struct GNUNET_TESTBED_Operation *op,
+                        void *ca_result, const char *emsg)
 {
   switch (sub_test)
   {
@@ -224,8 +228,9 @@
     GNUNET_assert (operation == op);
     GNUNET_assert (NULL == emsg);
     GNUNET_assert (NULL == cls);
+    GNUNET_assert (ca_result == dht_handle);
     GNUNET_TESTBED_operation_done (operation);        /* This results in call 
to
-                                                         * disconnect adapter 
*/
+                                                      * disconnect adapter */
     break;
   default:
     GNUNET_assert (0);
@@ -233,6 +238,7 @@
 }
 
 
+
 /**
  * Callback to be called when the requested peer information is available
  *
@@ -307,7 +313,8 @@
     GNUNET_assert (OTHER == sub_test);
     GNUNET_TESTBED_operation_done (operation);
     operation =
-        GNUNET_TESTBED_service_connect (NULL, peer, "dht", &op_comp_cb, NULL,
+        GNUNET_TESTBED_service_connect (NULL, peer, "dht", 
+                                       &service_connect_comp_cb, NULL,
                                        &dht_connect_adapter,
                                        &dht_disconnect_adapter, NULL);
     GNUNET_assert (NULL != operation);

Modified: gnunet/src/testbed/testbed_api_services.c
===================================================================
--- gnunet/src/testbed/testbed_api_services.c   2012-09-05 10:50:56 UTC (rev 
23655)
+++ gnunet/src/testbed/testbed_api_services.c   2012-09-05 11:44:56 UTC (rev 
23656)
@@ -110,7 +110,7 @@
   /**
    * The operation completion callback
    */
-  GNUNET_TESTBED_OperationCompletionCallback cb;
+  GNUNET_TESTBED_ServiceConnectCompletionCallback cb;
 
   /**
    * The closure for operation completion callback
@@ -161,7 +161,7 @@
       (NULL != c->cc))
     c->cc (c->cc_cls, &info);
   if (NULL != data->cb)
-    data->cb (data->cb_cls, data->operation, NULL);
+    data->cb (data->cb_cls, data->operation, data->op_result, NULL);
 }
 
 
@@ -247,7 +247,7 @@
 GNUNET_TESTBED_service_connect (void *op_cls,
                                struct GNUNET_TESTBED_Peer *peer,
                                const char *service_name,
-                                GNUNET_TESTBED_OperationCompletionCallback cb,
+                                
GNUNET_TESTBED_ServiceConnectCompletionCallback cb,
                                 void *cb_cls,
                                GNUNET_TESTBED_ConnectAdapter ca,
                                GNUNET_TESTBED_DisconnectAdapter da,




reply via email to

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