diff options
author | Bart Polot <bart@net.in.tum.de> | 2011-11-09 15:14:32 +0000 |
---|---|---|
committer | Bart Polot <bart@net.in.tum.de> | 2011-11-09 15:14:32 +0000 |
commit | 9114d323fa75eb629c98bdf0585ca71d6009cc3a (patch) | |
tree | 556ed130eb1d895a1691a22d2128a8b6a1fdffd9 /src | |
parent | 0f78d7c098a43c1670b3ac16b1b6139602c42f83 (diff) | |
download | gnunet-9114d323fa75eb629c98bdf0585ca71d6009cc3a.tar.gz gnunet-9114d323fa75eb629c98bdf0585ca71d6009cc3a.zip |
Added debug info, small fixes, doxygen.
Diffstat (limited to 'src')
-rw-r--r-- | src/testing/testing.c | 56 |
1 files changed, 55 insertions, 1 deletions
diff --git a/src/testing/testing.c b/src/testing/testing.c index fc022a0a0..c2905ea7f 100644 --- a/src/testing/testing.c +++ b/src/testing/testing.c | |||
@@ -124,11 +124,15 @@ process_hello (void *cls, const struct GNUNET_MessageHeader *message) | |||
124 | msize = ntohs (message->size); | 124 | msize = ntohs (message->size); |
125 | if (msize < 1) | 125 | if (msize < 1) |
126 | { | 126 | { |
127 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | ||
128 | "HELLO message of peer %s is of size 0\n", | ||
129 | GNUNET_i2s (&daemon->id)); | ||
127 | return; | 130 | return; |
128 | } | 131 | } |
129 | if (daemon->ghh != NULL) | 132 | if (daemon->ghh != NULL) |
130 | { | 133 | { |
131 | GNUNET_TRANSPORT_get_hello_cancel (daemon->ghh); | 134 | GNUNET_TRANSPORT_get_hello_cancel (daemon->ghh); |
135 | daemon->ghh = NULL; | ||
132 | } | 136 | } |
133 | #if DEBUG_TESTING | 137 | #if DEBUG_TESTING |
134 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 138 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
@@ -1970,6 +1974,13 @@ core_init_notify (void *cls, struct GNUNET_CORE_Handle *server, | |||
1970 | } | 1974 | } |
1971 | 1975 | ||
1972 | 1976 | ||
1977 | /** | ||
1978 | * Try to connect again some peers that failed in an earlier attempt. This will | ||
1979 | * be tried as many times as connection_attempts in the configuration file. | ||
1980 | * | ||
1981 | * @param cls Closure (connection context between the two peers). | ||
1982 | * @param tc TaskContext. | ||
1983 | */ | ||
1973 | static void | 1984 | static void |
1974 | reattempt_daemons_connect (void *cls, | 1985 | reattempt_daemons_connect (void *cls, |
1975 | const struct GNUNET_SCHEDULER_TaskContext *tc) | 1986 | const struct GNUNET_SCHEDULER_TaskContext *tc) |
@@ -2004,6 +2015,11 @@ reattempt_daemons_connect (void *cls, | |||
2004 | /* Don't know reason for initial connect failure, update the HELLO for the second peer */ | 2015 | /* Don't know reason for initial connect failure, update the HELLO for the second peer */ |
2005 | if (NULL != ctx->d2->hello) | 2016 | if (NULL != ctx->d2->hello) |
2006 | { | 2017 | { |
2018 | #if DEBUG_TESTING_RECONNECT | ||
2019 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
2020 | "updating %s's HELLO\n", | ||
2021 | ctx->d2->shortname); | ||
2022 | #endif | ||
2007 | GNUNET_free (ctx->d2->hello); | 2023 | GNUNET_free (ctx->d2->hello); |
2008 | ctx->d2->hello = NULL; | 2024 | ctx->d2->hello = NULL; |
2009 | if (NULL != ctx->d2->th) | 2025 | if (NULL != ctx->d2->th) |
@@ -2019,13 +2035,26 @@ reattempt_daemons_connect (void *cls, | |||
2019 | ctx->d2->ghh = | 2035 | ctx->d2->ghh = |
2020 | GNUNET_TRANSPORT_get_hello (ctx->d2->th, &process_hello, ctx->d2); | 2036 | GNUNET_TRANSPORT_get_hello (ctx->d2->th, &process_hello, ctx->d2); |
2021 | } | 2037 | } |
2038 | #if DEBUG_TESTING_RECONNECT | ||
2039 | else | ||
2040 | { | ||
2041 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
2042 | "didn't have %s's HELLO\n", | ||
2043 | ctx->d2->shortname); | ||
2044 | } | ||
2045 | #endif | ||
2022 | 2046 | ||
2023 | if ((NULL == ctx->d2->hello) && (ctx->d2->th == NULL)) | 2047 | if ((NULL == ctx->d2->hello) && (ctx->d2->th == NULL)) |
2024 | { | 2048 | { |
2049 | #if DEBUG_TESTING_RECONNECT | ||
2050 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
2051 | "didn't have %s's HELLO, trying to get it now\n", | ||
2052 | ctx->d2->shortname); | ||
2053 | #endif | ||
2025 | ctx->d2->th = | 2054 | ctx->d2->th = |
2026 | GNUNET_TRANSPORT_connect (ctx->d2->cfg, &ctx->d2->id, NULL, NULL, NULL, | 2055 | GNUNET_TRANSPORT_connect (ctx->d2->cfg, &ctx->d2->id, NULL, NULL, NULL, |
2027 | NULL); | 2056 | NULL); |
2028 | if (ctx->d2->th == NULL) | 2057 | if (NULL == ctx->d2->th) |
2029 | { | 2058 | { |
2030 | GNUNET_CORE_disconnect (ctx->d1core); | 2059 | GNUNET_CORE_disconnect (ctx->d1core); |
2031 | GNUNET_free (ctx); | 2060 | GNUNET_free (ctx); |
@@ -2038,9 +2067,25 @@ reattempt_daemons_connect (void *cls, | |||
2038 | ctx->d2->ghh = | 2067 | ctx->d2->ghh = |
2039 | GNUNET_TRANSPORT_get_hello (ctx->d2->th, &process_hello, ctx->d2); | 2068 | GNUNET_TRANSPORT_get_hello (ctx->d2->th, &process_hello, ctx->d2); |
2040 | } | 2069 | } |
2070 | #if DEBUG_TESTING_RECONNECT | ||
2071 | else | ||
2072 | { | ||
2073 | if (NULL == ctx->d2->hello) | ||
2074 | { | ||
2075 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
2076 | "didn't have %s's HELLO but th wasn't NULL, not trying!!\n", | ||
2077 | ctx->d2->shortname); | ||
2078 | } | ||
2079 | } | ||
2080 | #endif | ||
2041 | 2081 | ||
2042 | if (ctx->send_hello == GNUNET_YES) | 2082 | if (ctx->send_hello == GNUNET_YES) |
2043 | { | 2083 | { |
2084 | #if DEBUG_TESTING_RECONNECT | ||
2085 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
2086 | "Sending %s's HELLO to %s\n", | ||
2087 | ctx->d1->shortname, ctx->d2->shortname); | ||
2088 | #endif | ||
2044 | ctx->d1th = | 2089 | ctx->d1th = |
2045 | GNUNET_TRANSPORT_connect (ctx->d1->cfg, &ctx->d1->id, ctx->d1, NULL, | 2090 | GNUNET_TRANSPORT_connect (ctx->d1->cfg, &ctx->d1->id, ctx->d1, NULL, |
2046 | NULL, NULL); | 2091 | NULL, NULL); |
@@ -2059,6 +2104,11 @@ reattempt_daemons_connect (void *cls, | |||
2059 | } | 2104 | } |
2060 | else | 2105 | else |
2061 | { | 2106 | { |
2107 | #if DEBUG_TESTING_RECONNECT | ||
2108 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
2109 | "Trying to reconnect %s to %s\n", | ||
2110 | ctx->d1->shortname, ctx->d2->shortname); | ||
2111 | #endif | ||
2062 | GNUNET_TRANSPORT_try_connect (ctx->d1th, &ctx->d2->id); | 2112 | GNUNET_TRANSPORT_try_connect (ctx->d1th, &ctx->d2->id); |
2063 | } | 2113 | } |
2064 | ctx->timeout_task = | 2114 | ctx->timeout_task = |
@@ -2124,6 +2174,10 @@ core_initial_iteration (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
2124 | 2174 | ||
2125 | if ((NULL == ctx->d2->hello) && (ctx->d2->th == NULL)) /* Do not yet have the second peer's hello, set up a task to get it */ | 2175 | if ((NULL == ctx->d2->hello) && (ctx->d2->th == NULL)) /* Do not yet have the second peer's hello, set up a task to get it */ |
2126 | { | 2176 | { |
2177 | #if DEBUG_TESTING | ||
2178 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
2179 | "Don't have d2's HELLO, trying to get it!\n"); | ||
2180 | #endif | ||
2127 | ctx->d2->th = | 2181 | ctx->d2->th = |
2128 | GNUNET_TRANSPORT_connect (ctx->d2->cfg, &ctx->d2->id, NULL, NULL, NULL, | 2182 | GNUNET_TRANSPORT_connect (ctx->d2->cfg, &ctx->d2->id, NULL, NULL, NULL, |
2129 | NULL); | 2183 | NULL); |