From 57aab79c1d1b7036018eca127501632e85c4b37b Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Sun, 6 May 2012 18:53:13 +0000 Subject: [PATCH] -fixing #2309 --- src/transport/transport-testing.c | 68 +++++++++++++------------------ 1 file changed, 28 insertions(+), 40 deletions(-) diff --git a/src/transport/transport-testing.c b/src/transport/transport-testing.c index fd5cc4701..4e11f2c78 100644 --- a/src/transport/transport-testing.c +++ b/src/transport/transport-testing.c @@ -52,6 +52,7 @@ get_host_key (struct GNUNET_TRANSPORT_TESTING_handle *tth) return NULL; } + static struct PeerContext * find_peer_context (struct GNUNET_TRANSPORT_TESTING_handle *tth, const struct GNUNET_PeerIdentity *peer) @@ -69,7 +70,8 @@ find_peer_context (struct GNUNET_TRANSPORT_TESTING_handle *tth, return t; } -struct ConnectingContext * + +static struct ConnectingContext * find_connecting_context (struct GNUNET_TRANSPORT_TESTING_handle *tth, struct PeerContext *p1, struct PeerContext *p2) { @@ -88,6 +90,7 @@ find_connecting_context (struct GNUNET_TRANSPORT_TESTING_handle *tth, return cc; } + static void notify_connect (void *cls, const struct GNUNET_PeerIdentity *peer, const struct GNUNET_ATS_Information *ats, uint32_t ats_count) @@ -134,6 +137,7 @@ notify_connect (void *cls, const struct GNUNET_PeerIdentity *peer, } } + static void notify_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer) { @@ -167,6 +171,7 @@ notify_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer) p->nd (p->cb_cls, peer); } + static void notify_receive (void *cls, const struct GNUNET_PeerIdentity *peer, const struct GNUNET_MessageHeader *message, @@ -180,6 +185,7 @@ notify_receive (void *cls, const struct GNUNET_PeerIdentity *peer, p->rec (p->cb_cls, peer, message, ats, ats_count); } + static void get_hello (void *cb_cls, const struct GNUNET_MessageHeader *message) { @@ -307,11 +313,7 @@ GNUNET_TRANSPORT_TESTING_start_peer (struct GNUNET_TRANSPORT_TESTING_handle GNUNET_OS_start_process (GNUNET_YES, NULL, NULL, "gnunet-service-arm", "gnunet-service-arm", "-c", cfgname, -#if VERBOSE_PEERS - "-L", "DEBUG", -#else "-L", "ERROR", -#endif NULL); p->no = peer_id; @@ -361,10 +363,8 @@ GNUNET_TRANSPORT_TESTING_restart_peer (struct GNUNET_TRANSPORT_TESTING_handle GNUNET_assert (p->servicehome != NULL); /* shutdown */ -#if VERBOSE GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "transport-testing", "Stopping peer %u (`%s')\n", p->no, GNUNET_i2s (&p->id)); -#endif if (p->ghh != NULL) GNUNET_TRANSPORT_get_hello_cancel (p->ghh); p->ghh = NULL; @@ -390,11 +390,8 @@ GNUNET_TRANSPORT_TESTING_restart_peer (struct GNUNET_TRANSPORT_TESTING_handle /* start */ -#if VERBOSE GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "transport-testing", "Restarting peer %u (`%s')\n", p->no, GNUNET_i2s (&p->id)); -#endif - sleep (5); // YUCK! if (GNUNET_DISK_file_test (cfgname) == GNUNET_NO) @@ -424,11 +421,7 @@ GNUNET_TRANSPORT_TESTING_restart_peer (struct GNUNET_TRANSPORT_TESTING_handle GNUNET_OS_start_process (GNUNET_YES, NULL, NULL, "gnunet-service-arm", "gnunet-service-arm", "-c", cfgname, -#if VERBOSE_PEERS - "-L", "DEBUG", -#else "-L", "ERROR", -#endif NULL); p->th = @@ -451,6 +444,7 @@ fail: return GNUNET_SYSERR; } + /** * shutdown the given peer * @param tth testing handle @@ -508,6 +502,7 @@ GNUNET_TRANSPORT_TESTING_stop_peer (struct GNUNET_TRANSPORT_TESTING_handle *tth, p = NULL; } + /** * Connect the given peers and call the callback when both peers report the * inbound connection. Remarks: start_peer's notify_connect callback can be called @@ -559,6 +554,7 @@ GNUNET_TRANSPORT_TESTING_connect_peers (struct GNUNET_TRANSPORT_TESTING_handle * return cc; } + /** * Cancel the request to connect two peers * Tou MUST cancel the request if you stop the peers before the peers connected succesfully @@ -627,6 +623,7 @@ GNUNET_TRANSPORT_TESTING_done (struct GNUNET_TRANSPORT_TESTING_handle *tth) tth = NULL; } + /** * Initialize the transport testing * @return transport testing handle @@ -722,6 +719,7 @@ extract_filename (const char *file) return res; } + /** * Extracts the test filename from an absolute file name and removes the extension * @param file absolute file name @@ -781,7 +779,8 @@ GNUNET_TRANSPORT_TESTING_get_test_source_name (const char *file, char **dest) /** - * Extracts the plugin anme from an absolute file name and the test name + * Extracts the plugin name from an absolute file name and the test name + * * @param file absolute file name * @param test test name * @param dest where to store result @@ -790,43 +789,39 @@ void GNUNET_TRANSPORT_TESTING_get_test_plugin_name (const char *file, const char *test, char **dest) { + char *filename; + char *dotexe; char *e = extract_filename (file); char *t = extract_filename (test); - char *filename = NULL; - char *dotexe; - - if (e == NULL) + if (NULL == e) goto fail; - /* remove "lt-" */ filename = strstr (e, "tes"); - if (filename == NULL) + if (NULL == filename) goto fail; - /* remove ".exe" */ if (NULL != (dotexe = strstr (filename, ".exe"))) dotexe[0] = '\0'; /* find last _ */ filename = strstr (filename, t); - if (filename == NULL) + if (NULL == filename) goto fail; - /* copy plugin */ filename += strlen (t); - filename++; + if ('\0' != *filename) + filename++; GNUNET_asprintf (dest, "%s", filename); goto suc; - fail: (*dest) = NULL; suc: GNUNET_free (t); GNUNET_free (e); - } + /** * This function takes the filename (e.g. argv[0), removes a "lt-"-prefix and * if existing ".exe"-prefix and adds the peer-number @@ -843,30 +838,23 @@ GNUNET_TRANSPORT_TESTING_get_config_name (const char *file, char **dest, char *backup = filename; char *dotexe; - if (filename == NULL) + if (NULL == filename) goto fail; - /* remove "lt-" */ filename = strstr (filename, "tes"); - if (filename == NULL) + if (NULL == filename) goto fail; - /* remove ".exe" */ if (NULL != (dotexe = strstr (filename, ".exe"))) dotexe[0] = '\0'; - - goto suc; - + GNUNET_asprintf (dest, "%s_peer%u.conf", filename, count); + GNUNET_free (backup); + return; fail: (*dest) = NULL; - return; - -suc: - /* create cfg filename */ - GNUNET_asprintf (dest, "%s_peer%u.conf", filename, count); GNUNET_free (backup); } -/* end of transport_testing.h */ +/* end of transport-testing.c */ -- 2.25.1