aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Wachs <wachs@net.in.tum.de>2011-11-22 09:05:19 +0000
committerMatthias Wachs <wachs@net.in.tum.de>2011-11-22 09:05:19 +0000
commit0884d78b8fb7a867440802629698692c334bffbd (patch)
treeb564a125d6ef4c7f45e97516d183042b156a60bb
parentffabb052fa64eded69dffa1387b72df0ad1b0211 (diff)
downloadgnunet-0884d78b8fb7a867440802629698692c334bffbd.tar.gz
gnunet-0884d78b8fb7a867440802629698692c334bffbd.zip
-rw-r--r--src/transport/plugin_transport_udp.c2
-rw-r--r--src/transport/transport-testing.c97
-rw-r--r--src/transport/transport-testing.h12
3 files changed, 67 insertions, 44 deletions
diff --git a/src/transport/plugin_transport_udp.c b/src/transport/plugin_transport_udp.c
index d15bbe349..84c7ce661 100644
--- a/src/transport/plugin_transport_udp.c
+++ b/src/transport/plugin_transport_udp.c
@@ -1969,6 +1969,8 @@ iface_proc (void *cls, const char *name,
1969 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "netmask %s for interface %s %p\n ", 1969 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "netmask %s for interface %s %p\n ",
1970 GNUNET_a2s(netmask,addrlen), name, netmask); 1970 GNUNET_a2s(netmask,addrlen), name, netmask);
1971 1971
1972
1973 /* Collecting broadcast addresses*/
1972 if (broadcast_addr != NULL) 1974 if (broadcast_addr != NULL)
1973 { 1975 {
1974 struct BroadcastAddress * ba = GNUNET_malloc(sizeof (struct BroadcastAddress)); 1976 struct BroadcastAddress * ba = GNUNET_malloc(sizeof (struct BroadcastAddress));
diff --git a/src/transport/transport-testing.c b/src/transport/transport-testing.c
index 28d0db256..d11c885f8 100644
--- a/src/transport/transport-testing.c
+++ b/src/transport/transport-testing.c
@@ -27,7 +27,7 @@
27 27
28#include "transport-testing.h" 28#include "transport-testing.h"
29 29
30#define VERBOSE GNUNET_EXTRA_LOGGING 30#define VERBOSE GNUNET_YES
31#define HOSTKEYFILESIZE 914 31#define HOSTKEYFILESIZE 914
32 32
33static const char * 33static const char *
@@ -352,13 +352,21 @@ GNUNET_TRANSPORT_TESTING_start_peer (struct GNUNET_TRANSPORT_TESTING_handle
352* Restart the given peer 352* Restart the given peer
353* @param tth testing handle 353* @param tth testing handle
354* @param p the peer 354* @param p the peer
355* @param cfgname the cfg file used to restart
356* @return GNUNET_OK in success otherwise GNUNET_SYSERR
355*/ 357*/
356void 358int
357GNUNET_TRANSPORT_TESTING_restart_peer (struct GNUNET_TRANSPORT_TESTING_handle *tth, 359GNUNET_TRANSPORT_TESTING_restart_peer (struct GNUNET_TRANSPORT_TESTING_handle *tth,
358 struct PeerContext *p, 360 struct PeerContext *p,
359 const char *cfgname) 361 const char *cfgname)
360{ 362{
363 struct GNUNET_DISK_FileHandle *fn;
364 int success = GNUNET_OK;
365
361 GNUNET_assert (p != NULL); 366 GNUNET_assert (p != NULL);
367 GNUNET_assert (p->hostkeyfile != NULL);
368 GNUNET_assert (p->servicehome != NULL);
369
362 /* shutdown */ 370 /* shutdown */
363#if VERBOSE 371#if VERBOSE
364 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "transport-testing", 372 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "transport-testing",
@@ -394,52 +402,63 @@ GNUNET_TRANSPORT_TESTING_restart_peer (struct GNUNET_TRANSPORT_TESTING_handle *t
394 "Restarting peer %u (`%s')\n", p->no, 402 "Restarting peer %u (`%s')\n", p->no,
395 GNUNET_i2s (&p->id)); 403 GNUNET_i2s (&p->id));
396#endif 404#endif
397 struct GNUNET_DISK_FileHandle *fn; 405
398 406
399 GNUNET_assert (tth != NULL); 407 GNUNET_assert (tth != NULL);
400 if (GNUNET_DISK_file_test (cfgname) == GNUNET_NO) 408 if (GNUNET_DISK_file_test (cfgname) == GNUNET_NO)
401 { 409 {
402 GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, "transport-testing", 410 GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, "transport-testing",
403 "File not found: `%s' \n", cfgname); 411 "File not found: `%s' \n", cfgname);
404 return; 412 success = GNUNET_SYSERR;
413 goto fail;
405 } 414 }
406 415
407 p->cfg = GNUNET_CONFIGURATION_create (); 416 p->cfg = GNUNET_CONFIGURATION_create ();
408 GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname)); 417 GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname));
409 if (GNUNET_CONFIGURATION_have_value (p->cfg, "PATHS", "SERVICEHOME")) 418 if (GNUNET_CONFIGURATION_have_value (p->cfg, "PATHS", "SERVICEHOME"))
410 GNUNET_assert (GNUNET_OK == 419
411 GNUNET_CONFIGURATION_get_value_string (p->cfg, "PATHS", 420 fn = GNUNET_DISK_file_open (p->hostkeyfile,
412 "SERVICEHOME", 421 GNUNET_DISK_OPEN_READWRITE |
413 &p->servicehome)); 422 GNUNET_DISK_OPEN_CREATE,
414 423 GNUNET_DISK_PERM_USER_READ |
415 GNUNET_assert (p->hostkeyfile != NULL); 424 GNUNET_DISK_PERM_USER_WRITE);
416 GNUNET_asprintf (&p->hostkeyfile, "%s/.hostkey", p->servicehome); 425 if (fn == NULL)
417 fn = GNUNET_DISK_file_open (p->hostkeyfile, 426 {
418 GNUNET_DISK_OPEN_READWRITE | 427 success = GNUNET_SYSERR;
419 GNUNET_DISK_OPEN_CREATE, 428 goto fail;
420 GNUNET_DISK_PERM_USER_READ | 429 }
421 GNUNET_DISK_PERM_USER_WRITE); 430 if (GNUNET_OK != GNUNET_DISK_file_close (fn))
422 GNUNET_assert (fn != NULL); 431 {
423 GNUNET_assert (GNUNET_OK == GNUNET_DISK_file_close (fn)); 432 success = GNUNET_SYSERR;
424 433 goto fail;
425 p->arm_proc = GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm", 434 }
426 "gnunet-service-arm", "-c", cfgname, 435
427 #if VERBOSE_PEERS 436 p->arm_proc = GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm",
428 "-L", "DEBUG", 437 "gnunet-service-arm", "-c", cfgname,
429 #else 438 #if VERBOSE_PEERS
430 "-L", "ERROR", 439 "-L", "DEBUG",
431 #endif 440 #else
432 NULL); 441 "-L", "ERROR",
433 442 #endif
434 p->th = 443 NULL);
435 GNUNET_TRANSPORT_connect (p->cfg, NULL, p, &notify_receive, 444
436 &notify_connect, &notify_disconnect); 445 p->th =
437 GNUNET_assert (p->th != NULL); 446 GNUNET_TRANSPORT_connect (p->cfg, NULL, p, &notify_receive,
438 447 &notify_connect, &notify_disconnect);
439 p->ghh = GNUNET_TRANSPORT_get_hello (p->th, &get_hello, p); 448 GNUNET_assert (p->th != NULL);
440 GNUNET_assert (p->ghh != NULL); 449
441 450 p->ghh = GNUNET_TRANSPORT_get_hello (p->th, &get_hello, p);
442 return ; 451 GNUNET_assert (p->ghh != NULL);
452
453 fail:
454 if (success == GNUNET_SYSERR)
455 {
456 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "transport-testing",
457 "Restarting peer %u (`%s') failed, removing peer\n", p->no,
458 GNUNET_i2s (&p->id));
459 GNUNET_TRANSPORT_TESTING_stop_peer (tth,p);
460 }
461 return success;
443} 462}
444 463
445/** 464/**
diff --git a/src/transport/transport-testing.h b/src/transport/transport-testing.h
index 32641d8bc..6af2d68f5 100644
--- a/src/transport/transport-testing.h
+++ b/src/transport/transport-testing.h
@@ -161,11 +161,13 @@ GNUNET_TRANSPORT_TESTING_stop_peer (struct GNUNET_TRANSPORT_TESTING_handle *tth,
161 161
162 162
163/** 163/**
164 * Restart the given peer 164* Restart the given peer
165 * @param tth testing handle 165* @param tth testing handle
166 * @param p the peer 166* @param p the peer
167 */ 167* @param cfgname the cfg file used to restart
168void 168* @return GNUNET_OK in success otherwise GNUNET_SYSERR
169*/
170int
169GNUNET_TRANSPORT_TESTING_restart_peer (struct GNUNET_TRANSPORT_TESTING_handle *tth, 171GNUNET_TRANSPORT_TESTING_restart_peer (struct GNUNET_TRANSPORT_TESTING_handle *tth,
170 struct PeerContext *p, 172 struct PeerContext *p,
171 const char *cfgname); 173 const char *cfgname);