diff options
author | Sree Harsha Totakura <totakura@in.tum.de> | 2012-09-14 11:51:15 +0000 |
---|---|---|
committer | Sree Harsha Totakura <totakura@in.tum.de> | 2012-09-14 11:51:15 +0000 |
commit | 69eb1386d533c2ae921033e78647e7e76ae57990 (patch) | |
tree | daf1c4f2f32ce18ab7ba7b79dd1e757a574ac91a /src/testbed | |
parent | c27b4fe6e20d1d6b1ac29acba1b6030aec355064 (diff) | |
download | gnunet-69eb1386d533c2ae921033e78647e7e76ae57990.tar.gz gnunet-69eb1386d533c2ae921033e78647e7e76ae57990.zip |
more checks on while working on overlay connect request
Diffstat (limited to 'src/testbed')
-rw-r--r-- | src/testbed/gnunet-service-testbed.c | 32 |
1 files changed, 21 insertions, 11 deletions
diff --git a/src/testbed/gnunet-service-testbed.c b/src/testbed/gnunet-service-testbed.c index 9899f7491..f223913c4 100644 --- a/src/testbed/gnunet-service-testbed.c +++ b/src/testbed/gnunet-service-testbed.c | |||
@@ -2147,13 +2147,17 @@ core_startup_cb (void *cls, struct GNUNET_CORE_Handle *server, | |||
2147 | struct OverlayConnectContext *occ = cls; | 2147 | struct OverlayConnectContext *occ = cls; |
2148 | 2148 | ||
2149 | GNUNET_free_non_null (occ->emsg); | 2149 | GNUNET_free_non_null (occ->emsg); |
2150 | occ->emsg = GNUNET_strdup ("Failed to connect to CORE\n"); | ||
2151 | if ((NULL == server) || (NULL == my_identity)) | ||
2152 | goto error_return; | ||
2153 | GNUNET_free (occ->emsg); | ||
2150 | occ->emsg = NULL; | 2154 | occ->emsg = NULL; |
2151 | memcpy (&occ->peer_identity, my_identity, | 2155 | memcpy (&occ->peer_identity, my_identity, |
2152 | sizeof (struct GNUNET_PeerIdentity)); | 2156 | sizeof (struct GNUNET_PeerIdentity)); |
2153 | occ->p1th = | 2157 | occ->p1th = |
2154 | GNUNET_TRANSPORT_connect (occ->peer->details.local.cfg, | 2158 | GNUNET_TRANSPORT_connect (occ->peer->details.local.cfg, |
2155 | &occ->peer_identity, NULL, NULL, NULL, NULL); | 2159 | &occ->peer_identity, NULL, NULL, NULL, NULL); |
2156 | /* Connect to the transport of 2nd peer and get its HELLO message */ | 2160 | /* Connect to the transport of 2nd peer to offer 1st peer's HELLO */ |
2157 | GNUNET_TESTING_peer_get_identity (occ->other_peer->details.local.peer, | 2161 | GNUNET_TESTING_peer_get_identity (occ->other_peer->details.local.peer, |
2158 | &occ->other_peer_identity); | 2162 | &occ->other_peer_identity); |
2159 | occ->p2th = | 2163 | occ->p2th = |
@@ -2162,15 +2166,17 @@ core_startup_cb (void *cls, struct GNUNET_CORE_Handle *server, | |||
2162 | NULL); | 2166 | NULL); |
2163 | if ((NULL == occ->p1th) || (NULL == occ->p2th)) | 2167 | if ((NULL == occ->p1th) || (NULL == occ->p2th)) |
2164 | { | 2168 | { |
2165 | occ->emsg = GNUNET_strdup ("Cannot connect to TRANSPORTs of peers"); | 2169 | occ->emsg = GNUNET_strdup ("Cannot connect to TRANSPORTs of peers"); |
2166 | GNUNET_SCHEDULER_cancel (occ->timeout_task); | 2170 | goto error_return; |
2167 | occ->timeout_task = GNUNET_SCHEDULER_add_now (&timeout_overlay_connect, | ||
2168 | occ); | ||
2169 | return; | ||
2170 | } | 2171 | } |
2171 | LOG_DEBUG ("Acquiring HELLO of peer %s\n", GNUNET_i2s (&occ->peer_identity)); | 2172 | LOG_DEBUG ("Acquiring HELLO of peer %s\n", GNUNET_i2s (&occ->peer_identity)); |
2172 | occ->emsg = GNUNET_strdup ("Timeout while acquiring HELLO message"); | 2173 | occ->emsg = GNUNET_strdup ("Timeout while acquiring HELLO message"); |
2173 | occ->ghh = GNUNET_TRANSPORT_get_hello (occ->p1th, &hello_update_cb, occ); | 2174 | occ->ghh = GNUNET_TRANSPORT_get_hello (occ->p1th, &hello_update_cb, occ); |
2175 | return; | ||
2176 | |||
2177 | error_return: | ||
2178 | GNUNET_SCHEDULER_cancel (occ->timeout_task); | ||
2179 | occ->timeout_task = GNUNET_SCHEDULER_add_now (&timeout_overlay_connect, occ); | ||
2174 | } | 2180 | } |
2175 | 2181 | ||
2176 | 2182 | ||
@@ -2208,17 +2214,21 @@ handle_overlay_connect (void *cls, struct GNUNET_SERVER_Client *client, | |||
2208 | occ->client = client; | 2214 | occ->client = client; |
2209 | occ->peer = peer_list[p1]; | 2215 | occ->peer = peer_list[p1]; |
2210 | occ->other_peer = peer_list[p2]; | 2216 | occ->other_peer = peer_list[p2]; |
2211 | occ->op_id = GNUNET_ntohll (msg->operation_id); | 2217 | occ->op_id = GNUNET_ntohll (msg->operation_id); |
2212 | occ->timeout_task = | ||
2213 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply | ||
2214 | (GNUNET_TIME_UNIT_SECONDS, 30), | ||
2215 | &timeout_overlay_connect, occ); | ||
2216 | /* Connect to the core of 1st peer and wait for the 2nd peer to connect */ | 2218 | /* Connect to the core of 1st peer and wait for the 2nd peer to connect */ |
2217 | occ->emsg = GNUNET_strdup ("Timeout while connecting to CORE"); | 2219 | occ->emsg = GNUNET_strdup ("Timeout while connecting to CORE"); |
2218 | occ->ch = | 2220 | occ->ch = |
2219 | GNUNET_CORE_connect (occ->peer->details.local.cfg, occ, &core_startup_cb, | 2221 | GNUNET_CORE_connect (occ->peer->details.local.cfg, occ, &core_startup_cb, |
2220 | &overlay_connect_notify, NULL, NULL, GNUNET_NO, NULL, | 2222 | &overlay_connect_notify, NULL, NULL, GNUNET_NO, NULL, |
2221 | GNUNET_NO, no_handlers); | 2223 | GNUNET_NO, no_handlers); |
2224 | if (NULL == occ->ch) | ||
2225 | occ->timeout_task = | ||
2226 | GNUNET_SCHEDULER_add_now (&timeout_overlay_connect, occ); | ||
2227 | else | ||
2228 | occ->timeout_task = | ||
2229 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply | ||
2230 | (GNUNET_TIME_UNIT_SECONDS, 30), | ||
2231 | &timeout_overlay_connect, occ); | ||
2222 | GNUNET_SERVER_receive_done (client, GNUNET_OK); | 2232 | GNUNET_SERVER_receive_done (client, GNUNET_OK); |
2223 | } | 2233 | } |
2224 | 2234 | ||