gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r18245 - gnunet/src/transport


From: gnunet
Subject: [GNUnet-SVN] r18245 - gnunet/src/transport
Date: Tue, 22 Nov 2011 10:05:19 +0100

Author: wachs
Date: 2011-11-22 10:05:19 +0100 (Tue, 22 Nov 2011)
New Revision: 18245

Modified:
   gnunet/src/transport/plugin_transport_udp.c
   gnunet/src/transport/transport-testing.c
   gnunet/src/transport/transport-testing.h
Log:


Modified: gnunet/src/transport/plugin_transport_udp.c
===================================================================
--- gnunet/src/transport/plugin_transport_udp.c 2011-11-22 08:57:45 UTC (rev 
18244)
+++ gnunet/src/transport/plugin_transport_udp.c 2011-11-22 09:05:19 UTC (rev 
18245)
@@ -1969,6 +1969,8 @@
     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "netmask %s for interface %s %p\n ",
         GNUNET_a2s(netmask,addrlen), name, netmask);
 
+
+    /* Collecting broadcast addresses*/
     if (broadcast_addr != NULL)
     {
       struct BroadcastAddress * ba = GNUNET_malloc(sizeof (struct 
BroadcastAddress));

Modified: gnunet/src/transport/transport-testing.c
===================================================================
--- gnunet/src/transport/transport-testing.c    2011-11-22 08:57:45 UTC (rev 
18244)
+++ gnunet/src/transport/transport-testing.c    2011-11-22 09:05:19 UTC (rev 
18245)
@@ -27,7 +27,7 @@
 
 #include "transport-testing.h"
 
-#define VERBOSE GNUNET_EXTRA_LOGGING
+#define VERBOSE GNUNET_YES
 #define HOSTKEYFILESIZE 914
 
 static const char *
@@ -352,13 +352,21 @@
 * Restart the given peer
 * @param tth testing handle
 * @param p the peer
+* @param cfgname the cfg file used to restart
+* @return GNUNET_OK in success otherwise GNUNET_SYSERR
 */
-void
+int
 GNUNET_TRANSPORT_TESTING_restart_peer (struct GNUNET_TRANSPORT_TESTING_handle 
*tth,
                                        struct PeerContext *p,
                                        const char *cfgname)
 {
+  struct GNUNET_DISK_FileHandle *fn;
+  int success = GNUNET_OK;
+
   GNUNET_assert (p != NULL);
+  GNUNET_assert (p->hostkeyfile != NULL);
+  GNUNET_assert (p->servicehome != NULL);
+
   /* shutdown */
 #if VERBOSE
     GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "transport-testing",
@@ -394,52 +402,63 @@
                      "Restarting peer %u (`%s')\n", p->no,
                      GNUNET_i2s (&p->id));
 #endif
-  struct GNUNET_DISK_FileHandle *fn;
 
+
   GNUNET_assert (tth != NULL);
   if (GNUNET_DISK_file_test (cfgname) == GNUNET_NO)
   {
-   GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, "transport-testing",
-                    "File not found: `%s' \n", cfgname);
-   return;
+  GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, "transport-testing",
+                  "File not found: `%s' \n", cfgname);
+  success = GNUNET_SYSERR;
+  goto fail;
   }
 
   p->cfg = GNUNET_CONFIGURATION_create ();
   GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname));
   if (GNUNET_CONFIGURATION_have_value (p->cfg, "PATHS", "SERVICEHOME"))
-   GNUNET_assert (GNUNET_OK ==
-                  GNUNET_CONFIGURATION_get_value_string (p->cfg, "PATHS",
-                                                         "SERVICEHOME",
-                                                         &p->servicehome));
 
-   GNUNET_assert (p->hostkeyfile != NULL);
-   GNUNET_asprintf (&p->hostkeyfile, "%s/.hostkey", p->servicehome);
-   fn = GNUNET_DISK_file_open (p->hostkeyfile,
-                               GNUNET_DISK_OPEN_READWRITE |
-                               GNUNET_DISK_OPEN_CREATE,
-                               GNUNET_DISK_PERM_USER_READ |
-                               GNUNET_DISK_PERM_USER_WRITE);
-   GNUNET_assert (fn != NULL);
-   GNUNET_assert (GNUNET_OK == GNUNET_DISK_file_close (fn));
+  fn = GNUNET_DISK_file_open (p->hostkeyfile,
+                             GNUNET_DISK_OPEN_READWRITE |
+                             GNUNET_DISK_OPEN_CREATE,
+                             GNUNET_DISK_PERM_USER_READ |
+                             GNUNET_DISK_PERM_USER_WRITE);
+  if (fn == NULL)
+  {
+   success = GNUNET_SYSERR;
+   goto fail;
+  }
+  if (GNUNET_OK != GNUNET_DISK_file_close (fn))
+  {
+   success = GNUNET_SYSERR;
+   goto fail;
+  }
 
-   p->arm_proc = GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm",
-                                "gnunet-service-arm", "-c", cfgname,
- #if VERBOSE_PEERS
-                                "-L", "DEBUG",
- #else
-                                "-L", "ERROR",
- #endif
-                                NULL);
+  p->arm_proc = GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm",
+                              "gnunet-service-arm", "-c", cfgname,
+  #if VERBOSE_PEERS
+                              "-L", "DEBUG",
+  #else
+                              "-L", "ERROR",
+  #endif
+                              NULL);
 
-   p->th =
-       GNUNET_TRANSPORT_connect (p->cfg, NULL, p, &notify_receive,
-                                 &notify_connect, &notify_disconnect);
-   GNUNET_assert (p->th != NULL);
+  p->th =
+     GNUNET_TRANSPORT_connect (p->cfg, NULL, p, &notify_receive,
+                               &notify_connect, &notify_disconnect);
+  GNUNET_assert (p->th != NULL);
 
-   p->ghh = GNUNET_TRANSPORT_get_hello (p->th, &get_hello, p);
-   GNUNET_assert (p->ghh != NULL);
+  p->ghh = GNUNET_TRANSPORT_get_hello (p->th, &get_hello, p);
+  GNUNET_assert (p->ghh != NULL);
 
-   return ;
+  fail:
+  if (success == GNUNET_SYSERR)
+  {
+   GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "transport-testing",
+                    "Restarting peer %u (`%s') failed, removing peer\n", p->no,
+                    GNUNET_i2s (&p->id));
+   GNUNET_TRANSPORT_TESTING_stop_peer (tth,p);
+  }
+  return success;
 }
 
 /**

Modified: gnunet/src/transport/transport-testing.h
===================================================================
--- gnunet/src/transport/transport-testing.h    2011-11-22 08:57:45 UTC (rev 
18244)
+++ gnunet/src/transport/transport-testing.h    2011-11-22 09:05:19 UTC (rev 
18245)
@@ -161,11 +161,13 @@
 
 
 /**
- * Restart the given peer
- * @param tth testing handle
- * @param p the peer
- */
-void
+* Restart the given peer
+* @param tth testing handle
+* @param p the peer
+* @param cfgname the cfg file used to restart
+* @return GNUNET_OK in success otherwise GNUNET_SYSERR
+*/
+int
 GNUNET_TRANSPORT_TESTING_restart_peer (struct GNUNET_TRANSPORT_TESTING_handle 
*tth,
                                        struct PeerContext *p,
                                        const char *cfgname);




reply via email to

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