gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r37908 - gnunet/src/multicast


From: gnunet
Subject: [GNUnet-SVN] r37908 - gnunet/src/multicast
Date: Sun, 11 Sep 2016 17:46:08 +0200

Author: grothoff
Date: 2016-09-11 17:46:08 +0200 (Sun, 11 Sep 2016)
New Revision: 37908

Modified:
   gnunet/src/multicast/test_multicast_multipeer.c
Log:
-misc fixes to test:


Modified: gnunet/src/multicast/test_multicast_multipeer.c
===================================================================
--- gnunet/src/multicast/test_multicast_multipeer.c     2016-09-07 22:31:05 UTC 
(rev 37907)
+++ gnunet/src/multicast/test_multicast_multipeer.c     2016-09-11 15:46:08 UTC 
(rev 37908)
@@ -39,7 +39,7 @@
 static struct GNUNET_TESTBED_Operation *multicast_peer0;
 static struct GNUNET_TESTBED_Operation *multicast_peer1;
 
-static struct GNUNET_SCHEDULER_Task * shutdown_tid;
+static struct GNUNET_SCHEDULER_Task *timeout_tid;
 
 
 /**
@@ -55,34 +55,67 @@
 static void
 shutdown_task (void *cls)
 {
-  shutdown_tid = NULL;
-  //if (NULL != dht_op)
-  //{
-    // GNUNET_TESTBED_operation_done (dht_op); 
-    //dht_op = NULL;
-    //dht_handle = NULL;
-  //}
-  result = GNUNET_OK;
-  GNUNET_SCHEDULER_shutdown (); /* Also kills the testbed */
+  if (NULL != multicast_peer0)
+  {
+    GNUNET_TESTBED_operation_done (multicast_peer0); 
+    multicast_peer0 = NULL;
+  }
+  if (NULL != timeout_tid)
+    {
+      GNUNET_SCHEDULER_cancel (timeout_tid);
+      timeout_tid = NULL;
+    }
 }
 
 
+static void
+timeout_task (void *cls)
+{
+  timeout_tid = NULL;
+  GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+             "Timeout!\n");
+  result = GNUNET_SYSERR;
+  GNUNET_SCHEDULER_shutdown ();
+}
+
+
 static void 
-service_close_peer0 (void *cls, void *op_result) {
-  /* Disconnect from service */
+service_close_peer0 (void *cls,
+                    void *op_result)
+{
+  struct GNUNET_MULTICAST_Origin *orig = op_result;
+  
+  GNUNET_MULTICAST_origin_stop (orig,
+                               NULL,
+                               NULL);
 }
 
+
 /**
  * Function run when service multicast has started and is providing us
  * with a configuration file.
  */ 
 static void *
-service_conf_peer0 (void *cls, const struct GNUNET_CONFIGURATION_Handle *cfg)
+service_conf_peer0 (void *cls,
+                   const struct GNUNET_CONFIGURATION_Handle *cfg)
 {
-  /* Use the provided configuration to connect to service */
+  #if 0
+  return GNUNET_MULTICAST_origin_start (cfg,
+                                       priv_key,
+                                       42,
+                                       &join_rcb,
+                                       &reply_fcb,
+                                       &reply_mcb,
+                                       &request_cb,
+                                       &message_cb,
+                                       NULL);
+#else
   return NULL;
+
+#endif
 }
 
+
 /**
  * Test logic of peer "0" being origin starts here. 
  *
@@ -95,14 +128,19 @@
  */
 static void
 service_connect_peer0 (void *cls,
-        struct GNUNET_TESTBED_Operation *op,
-        void *ca_result,
-        const char *emsg)
+                      struct GNUNET_TESTBED_Operation *op,
+                      void *ca_result,
+                      const char *emsg)
 {
+  struct GNUNET_MULTICAST_Origin *orig = ca_result;
+
   /* Connection to service successful. Here we'd usually do something with 
    * the service. */
+  result = GNUNET_OK;
+  GNUNET_SCHEDULER_shutdown (); /* Also kills the testbed */
 }
 
+
 /**
  * Main function inovked from TESTBED once all of the
  * peers are up and running.  This one then connects
@@ -135,16 +173,17 @@
       (NULL,                    /* Closure for operation */
        peers[0],                /* The peer whose service to connect to */
        "multicast",             /* The name of the service */
-       service_connect_peer0,   /* callback to call after a handle to service
+       &service_connect_peer0,   /* callback to call after a handle to service
                                    is opened */
        NULL,                    /* closure for the above callback */
-       service_conf_peer0,      /* callback to call with peer's configuration;
+       &service_conf_peer0,      /* callback to call with peer's configuration;
                                    this should open the needed service 
connection */
-       service_close_peer0,     /* callback to be called when closing the
+       &service_close_peer0,     /* callback to be called when closing the
                                    opened service connection */
        NULL);                   /* closure for the above two callbacks */
-  shutdown_tid = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_MINUTES,
-                                               &shutdown_task, NULL);
+  GNUNET_SCHEDULER_add_shutdown (&shutdown_task, NULL);
+  timeout_tid = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_MINUTES,
+                                             &timeout_task, NULL);
 }
 
 




reply via email to

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