-bugfixes
authorChristian Grothoff <christian@grothoff.org>
Tue, 24 Jan 2012 14:42:51 +0000 (14:42 +0000)
committerChristian Grothoff <christian@grothoff.org>
Tue, 24 Jan 2012 14:42:51 +0000 (14:42 +0000)
src/vpn/test_gnunet_vpn.c
src/vpn/vpn_api.c

index f75abac990161579c4c30595044d4e409d18b6c0..4d8ee7e9ca5af452ae5411cca5905137d36932d3 100644 (file)
@@ -254,7 +254,13 @@ allocation_cb (void *cls,
   char ips[INET_ADDRSTRLEN];
 
   rr = NULL;
-  GNUNET_assert (AF_INET == af);
+  if (AF_INET != af)
+  {
+    fprintf (stderr, 
+z           "VPN failed to allocate appropriate address\n");
+    GNUNET_SCHEDULER_shutdown ();
+    return;
+  }
   GNUNET_asprintf (&url, 
                   "http://%s:%u/hello_world",  
                   inet_ntop (af, address, ips, sizeof (ips)),
@@ -341,9 +347,6 @@ mhd_main ()
                                             &nws,
                                             &mhd_task,
                                             NULL);  
-  ctrl_c_task_id = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL,
-                                                &ctrl_c_shutdown,
-                                                NULL);
 }
 
 
@@ -373,6 +376,9 @@ run (void *cls, char *const *args, const char *cfgfile,
                                  GNUNET_YES,
                                  GNUNET_TIME_UNIT_FOREVER_ABS,
                                  &allocation_cb, NULL);
+  ctrl_c_task_id = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL,
+                                                &ctrl_c_shutdown,
+                                                NULL);
 }
 
 
@@ -430,15 +436,6 @@ main (int argc, char *const *argv)
     GNUNET_GETOPT_OPTION_END
   };
 
-  /* not technically true -- proper SUID and a chdir here would
-     likely do -- but this will avoid getting (useless) reports
-     from users where the test fails due to insufficient
-     permissions */
-  if (0 != getuid ())
-  {
-    fprintf (stderr, "This testcase can only be run as root\n");
-    return 0;
-  }
   if (0 != curl_global_init (CURL_GLOBAL_WIN32))
     return 2;
   setup_peer (&p1, "test_gnunet_vpn.conf");
@@ -452,5 +449,6 @@ main (int argc, char *const *argv)
   GNUNET_PROGRAM_run ((sizeof (argvx) / sizeof (char *)) - 1, argvx,
                       "test_gnunet_vpn", "nohelp", options, &run, NULL);
   stop_peer (&p1);
+  GNUNET_DISK_directory_remove ("/tmp/gnunet-test-vpn");
   return global_ret;
 }
index 3f8d0452393b8872df0884412bfbddd08fdb095c..494c6d8573262a8648faf2b629ff1aff910055af 100644 (file)
@@ -261,9 +261,13 @@ transmit_request (void *cls,
   while ( (NULL != rr) &&
          (0 != rr->request_id) )
     rr = rr->next;
-  if ( (NULL == rr) ||
-       (0 == size) )
+  if (NULL == rr) 
     return 0;
+  if (0 == size) 
+  {
+    reconnect (vh);
+    return 0;
+  }
 
   /* if first request, start receive loop */
   if (0 == vh->request_id_gen)
@@ -364,9 +368,10 @@ connect_task (void *cls,
 {
   struct GNUNET_VPN_Handle *vh = cls;
   
+  vh->rt = GNUNET_SCHEDULER_NO_TASK;
   vh->client = GNUNET_CLIENT_connect ("vpn", vh->cfg);
   GNUNET_assert (NULL != vh->client);
-  GNUNET_assert (NULL != vh->th);
+  GNUNET_assert (NULL == vh->th);
   if (NULL != vh->rr_head) 
     vh->th = GNUNET_CLIENT_notify_transmit_ready (vh->client,
                                                  sizeof (struct RedirectToServiceRequestMessage),