aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/testbed/gnunet-service-testbed_oc.c75
1 files changed, 35 insertions, 40 deletions
diff --git a/src/testbed/gnunet-service-testbed_oc.c b/src/testbed/gnunet-service-testbed_oc.c
index 5096f671d..79ac03bf1 100644
--- a/src/testbed/gnunet-service-testbed_oc.c
+++ b/src/testbed/gnunet-service-testbed_oc.c
@@ -192,12 +192,7 @@ struct OverlayConnectContext
192 GNUNET_SCHEDULER_TaskIdentifier cleanup_task; 192 GNUNET_SCHEDULER_TaskIdentifier cleanup_task;
193 193
194 /** 194 /**
195 * The id of peer A 195 * The id of the second peer which is has to connect to the first peer
196 */
197 uint32_t peer_id;
198
199 /**
200 * The id of peer B
201 */ 196 */
202 uint32_t other_peer_id; 197 uint32_t other_peer_id;
203 198
@@ -395,6 +390,8 @@ GST_process_next_focc (struct RegisteredHostContext *rhc)
395static void 390static void
396cleanup_occ (struct OverlayConnectContext *occ) 391cleanup_occ (struct OverlayConnectContext *occ)
397{ 392{
393 struct Peer *other_peer;
394
398 LOG_DEBUG ("0x%llx: Cleaning up occ\n", occ->op_id); 395 LOG_DEBUG ("0x%llx: Cleaning up occ\n", occ->op_id);
399 GNUNET_free_non_null (occ->emsg); 396 GNUNET_free_non_null (occ->emsg);
400 GNUNET_free_non_null (occ->hello); 397 GNUNET_free_non_null (occ->hello);
@@ -408,10 +405,7 @@ cleanup_occ (struct OverlayConnectContext *occ)
408 if (GNUNET_SCHEDULER_NO_TASK != occ->timeout_task) 405 if (GNUNET_SCHEDULER_NO_TASK != occ->timeout_task)
409 GNUNET_SCHEDULER_cancel (occ->timeout_task); 406 GNUNET_SCHEDULER_cancel (occ->timeout_task);
410 if (NULL != occ->cgh_ch) 407 if (NULL != occ->cgh_ch)
411 {
412 GST_cache_get_handle_done (occ->cgh_ch); 408 GST_cache_get_handle_done (occ->cgh_ch);
413 occ->peer->reference_cnt--;
414 }
415 if (NULL != occ->ghh) 409 if (NULL != occ->ghh)
416 GNUNET_TRANSPORT_get_hello_cancel (occ->ghh); 410 GNUNET_TRANSPORT_get_hello_cancel (occ->ghh);
417 if (NULL != occ->ohh) 411 if (NULL != occ->ohh)
@@ -421,22 +415,25 @@ cleanup_occ (struct OverlayConnectContext *occ)
421 if (NULL != occ->tcc.tch) 415 if (NULL != occ->tcc.tch)
422 GNUNET_TRANSPORT_try_connect_cancel (occ->tcc.tch); 416 GNUNET_TRANSPORT_try_connect_cancel (occ->tcc.tch);
423 if (NULL != occ->cgh_p1th) 417 if (NULL != occ->cgh_p1th)
424 {
425 GST_cache_get_handle_done (occ->cgh_p1th); 418 GST_cache_get_handle_done (occ->cgh_p1th);
426 occ->peer->reference_cnt--;
427 }
428 if (NULL != occ->tcc.cgh_th) 419 if (NULL != occ->tcc.cgh_th)
429 {
430 GST_cache_get_handle_done (occ->tcc.cgh_th); 420 GST_cache_get_handle_done (occ->tcc.cgh_th);
431 GST_peer_list[occ->other_peer_id]->reference_cnt--; 421 GNUNET_assert (NULL != GST_peer_list);
432 } 422 GNUNET_assert (occ->peer->reference_cnt > 0);
433 if ((GNUNET_YES == occ->peer->destroy_flag) && 423 occ->peer->reference_cnt--;
434 (0 == occ->peer->reference_cnt)) 424 if ( (GNUNET_YES == occ->peer->destroy_flag) &&
425 (0 == occ->peer->reference_cnt) )
435 GST_destroy_peer (occ->peer); 426 GST_destroy_peer (occ->peer);
436 if ((NULL == occ->peer2_controller) && 427 if (NULL == occ->peer2_controller)
437 (GNUNET_YES == GST_peer_list[occ->other_peer_id]->destroy_flag) && 428 {
438 (0 == GST_peer_list[occ->other_peer_id]->reference_cnt)) 429 other_peer = GST_peer_list[occ->other_peer_id];
439 GST_destroy_peer (GST_peer_list[occ->other_peer_id]); 430 GNUNET_assert (NULL != other_peer);
431 GNUNET_assert (other_peer->reference_cnt > 0);
432 other_peer->reference_cnt--;
433 if ( (GNUNET_YES == other_peer->destroy_flag) &&
434 (0 == other_peer->reference_cnt) )
435 GST_destroy_peer (other_peer);
436 }
440 GNUNET_CONTAINER_DLL_remove (occq_head, occq_tail, occ); 437 GNUNET_CONTAINER_DLL_remove (occq_head, occq_tail, occ);
441 GNUNET_free (occ); 438 GNUNET_free (occ);
442} 439}
@@ -474,7 +471,7 @@ timeout_overlay_connect (void *cls,
474 occ->timeout_task = GNUNET_SCHEDULER_NO_TASK; 471 occ->timeout_task = GNUNET_SCHEDULER_NO_TASK;
475 LOG (GNUNET_ERROR_TYPE_WARNING, 472 LOG (GNUNET_ERROR_TYPE_WARNING,
476 "0x%llx: Timeout while connecting peers %u and %u: %s\n", occ->op_id, 473 "0x%llx: Timeout while connecting peers %u and %u: %s\n", occ->op_id,
477 occ->peer_id, occ->other_peer_id, occ->emsg); 474 occ->peer->id, occ->other_peer_id, occ->emsg);
478 GST_send_operation_fail_msg (occ->client, occ->op_id, occ->emsg); 475 GST_send_operation_fail_msg (occ->client, occ->op_id, occ->emsg);
479 cleanup_occ (occ); 476 cleanup_occ (occ);
480} 477}
@@ -492,7 +489,7 @@ send_overlay_connect_success_msg (struct OverlayConnectContext *occ)
492 htons (sizeof (struct GNUNET_TESTBED_ConnectionEventMessage)); 489 htons (sizeof (struct GNUNET_TESTBED_ConnectionEventMessage));
493 msg->header.type = htons (GNUNET_MESSAGE_TYPE_TESTBED_PEER_CONNECT_EVENT); 490 msg->header.type = htons (GNUNET_MESSAGE_TYPE_TESTBED_PEER_CONNECT_EVENT);
494 msg->event_type = htonl (GNUNET_TESTBED_ET_CONNECT); 491 msg->event_type = htonl (GNUNET_TESTBED_ET_CONNECT);
495 msg->peer1 = htonl (occ->peer_id); 492 msg->peer1 = htonl (occ->peer->id);
496 msg->peer2 = htonl (occ->other_peer_id); 493 msg->peer2 = htonl (occ->other_peer_id);
497 msg->operation_id = GNUNET_htonll (occ->op_id); 494 msg->operation_id = GNUNET_htonll (occ->op_id);
498 GST_queue_message (occ->client, &msg->header); 495 GST_queue_message (occ->client, &msg->header);
@@ -769,11 +766,11 @@ p2_transport_connect (struct OverlayConnectContext *occ)
769 GNUNET_assert (NULL == occ->cgh_p1th); 766 GNUNET_assert (NULL == occ->cgh_p1th);
770 if (NULL == occ->peer2_controller) 767 if (NULL == occ->peer2_controller)
771 { 768 {
772 GST_peer_list[occ->other_peer_id]->reference_cnt++; 769 GNUNET_assert (NULL != GST_peer_list[occ->other_peer_id]);
773 occ->tcc.cgh_th = 770 occ->tcc.cgh_th =
774 GST_cache_get_handle_transport (occ->other_peer_id, 771 GST_cache_get_handle_transport (occ->other_peer_id,
775 GST_peer_list[occ->other_peer_id]-> 772 GST_peer_list[occ->other_peer_id]
776 details.local.cfg, 773 ->details.local.cfg,
777 &p2_transport_connect_cache_callback, 774 &p2_transport_connect_cache_callback,
778 occ, NULL, NULL, NULL); 775 occ, NULL, NULL, NULL);
779 return; 776 return;
@@ -832,12 +829,11 @@ hello_update_cb (void *cls, const struct GNUNET_MessageHeader *hello)
832 LOG_DEBUG ("0x%llx: Received HELLO of %s\n", occ->op_id, 829 LOG_DEBUG ("0x%llx: Received HELLO of %s\n", occ->op_id,
833 GNUNET_i2s (&occ->peer_identity)); 830 GNUNET_i2s (&occ->peer_identity));
834 occ->hello = GNUNET_malloc (msize); 831 occ->hello = GNUNET_malloc (msize);
835 GST_cache_add_hello (occ->peer_id, hello); 832 GST_cache_add_hello (occ->peer->id, hello);
836 memcpy (occ->hello, hello, msize); 833 memcpy (occ->hello, hello, msize);
837 GNUNET_TRANSPORT_get_hello_cancel (occ->ghh); 834 GNUNET_TRANSPORT_get_hello_cancel (occ->ghh);
838 occ->ghh = NULL; 835 occ->ghh = NULL;
839 GST_cache_get_handle_done (occ->cgh_p1th); 836 GST_cache_get_handle_done (occ->cgh_p1th);
840 occ->peer->reference_cnt--;
841 occ->cgh_p1th = NULL; 837 occ->cgh_p1th = NULL;
842 occ->p1th_ = NULL; 838 occ->p1th_ = NULL;
843 GNUNET_free_non_null (occ->emsg); 839 GNUNET_free_non_null (occ->emsg);
@@ -904,7 +900,7 @@ occ_cache_get_handle_core_cb (void *cls, struct GNUNET_CORE_Handle *ch,
904 { 900 {
905 (void) GNUNET_asprintf (&occ->emsg, 901 (void) GNUNET_asprintf (&occ->emsg,
906 "0x%llx: Failed to connect to CORE of peer with" 902 "0x%llx: Failed to connect to CORE of peer with"
907 "id: %u", occ->op_id, occ->peer_id); 903 "id: %u", occ->op_id, occ->peer->id);
908 GNUNET_SCHEDULER_cancel (occ->timeout_task); 904 GNUNET_SCHEDULER_cancel (occ->timeout_task);
909 occ->timeout_task = 905 occ->timeout_task =
910 GNUNET_SCHEDULER_add_now (&timeout_overlay_connect, occ); 906 GNUNET_SCHEDULER_add_now (&timeout_overlay_connect, occ);
@@ -927,7 +923,7 @@ occ_cache_get_handle_core_cb (void *cls, struct GNUNET_CORE_Handle *ch,
927 LOG_DEBUG ("0x%llx: Acquiring HELLO of peer %s\n", occ->op_id, 923 LOG_DEBUG ("0x%llx: Acquiring HELLO of peer %s\n", occ->op_id,
928 GNUNET_i2s (&occ->peer_identity)); 924 GNUNET_i2s (&occ->peer_identity));
929 /* Lookup for HELLO in hello cache */ 925 /* Lookup for HELLO in hello cache */
930 if (NULL != (hello = GST_cache_lookup_hello (occ->peer_id))) 926 if (NULL != (hello = GST_cache_lookup_hello (occ->peer->id)))
931 { 927 {
932 LOG_DEBUG ("0x%llx: HELLO of peer %s found in cache\n", occ->op_id, 928 LOG_DEBUG ("0x%llx: HELLO of peer %s found in cache\n", occ->op_id,
933 GNUNET_i2s (&occ->peer_identity)); 929 GNUNET_i2s (&occ->peer_identity));
@@ -938,9 +934,8 @@ occ_cache_get_handle_core_cb (void *cls, struct GNUNET_CORE_Handle *ch,
938 GNUNET_asprintf (&occ->emsg, 934 GNUNET_asprintf (&occ->emsg,
939 "0x%llx: Timeout while acquiring TRANSPORT of %s from cache", 935 "0x%llx: Timeout while acquiring TRANSPORT of %s from cache",
940 occ->op_id, GNUNET_i2s (&occ->peer_identity)); 936 occ->op_id, GNUNET_i2s (&occ->peer_identity));
941 occ->peer->reference_cnt++;
942 occ->cgh_p1th = 937 occ->cgh_p1th =
943 GST_cache_get_handle_transport (occ->peer_id, 938 GST_cache_get_handle_transport (occ->peer->id,
944 occ->peer->details.local.cfg, 939 occ->peer->details.local.cfg,
945 p1_transport_connect_cache_callback, occ, 940 p1_transport_connect_cache_callback, occ,
946 NULL, NULL, NULL); 941 NULL, NULL, NULL);
@@ -977,10 +972,9 @@ overlay_connect_get_config (void *cls, const struct GNUNET_MessageHeader *msg)
977 GNUNET_free_non_null (occ->emsg); 972 GNUNET_free_non_null (occ->emsg);
978 GNUNET_asprintf (&occ->emsg, 973 GNUNET_asprintf (&occ->emsg,
979 "0x%llx: Timeout while connecting to CORE of peer with " 974 "0x%llx: Timeout while connecting to CORE of peer with "
980 "id: %u", occ->op_id, occ->peer_id); 975 "id: %u", occ->op_id, occ->peer->id);
981 occ->peer->reference_cnt++;
982 occ->cgh_ch = 976 occ->cgh_ch =
983 GST_cache_get_handle_core (occ->peer_id, occ->peer->details.local.cfg, 977 GST_cache_get_handle_core (occ->peer->id, occ->peer->details.local.cfg,
984 occ_cache_get_handle_core_cb, occ, 978 occ_cache_get_handle_core_cb, occ,
985 &occ->other_peer_identity, 979 &occ->other_peer_identity,
986 &overlay_connect_notify, occ); 980 &overlay_connect_notify, occ);
@@ -1259,9 +1253,9 @@ GST_handle_overlay_connect (void *cls, struct GNUNET_SERVER_Client *client,
1259 GNUNET_CONTAINER_DLL_insert_tail (occq_head, occq_tail, occ); 1253 GNUNET_CONTAINER_DLL_insert_tail (occq_head, occq_tail, occ);
1260 GNUNET_SERVER_client_keep (client); 1254 GNUNET_SERVER_client_keep (client);
1261 occ->client = client; 1255 occ->client = client;
1262 occ->peer_id = p1;
1263 occ->other_peer_id = p2; 1256 occ->other_peer_id = p2;
1264 occ->peer = GST_peer_list[p1]; 1257 GST_peer_list[p1]->reference_cnt++;
1258 occ->peer = GST_peer_list[p1];
1265 occ->op_id = GNUNET_ntohll (msg->operation_id); 1259 occ->op_id = GNUNET_ntohll (msg->operation_id);
1266 occ->peer2_controller = peer2_controller; 1260 occ->peer2_controller = peer2_controller;
1267 GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == occ->timeout_task); 1261 GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == occ->timeout_task);
@@ -1289,15 +1283,15 @@ GST_handle_overlay_connect (void *cls, struct GNUNET_SERVER_Client *client,
1289 GNUNET_SERVER_receive_done (client, GNUNET_OK); 1283 GNUNET_SERVER_receive_done (client, GNUNET_OK);
1290 return; 1284 return;
1291 } 1285 }
1286 GST_peer_list[occ->other_peer_id]->reference_cnt++;
1292 GNUNET_TESTING_peer_get_identity (GST_peer_list[occ->other_peer_id]-> 1287 GNUNET_TESTING_peer_get_identity (GST_peer_list[occ->other_peer_id]->
1293 details.local.peer, 1288 details.local.peer,
1294 &occ->other_peer_identity); 1289 &occ->other_peer_identity);
1295 GNUNET_asprintf (&occ->emsg, 1290 GNUNET_asprintf (&occ->emsg,
1296 "0x%llx: Timeout while connecting to CORE of peer with " 1291 "0x%llx: Timeout while connecting to CORE of peer with "
1297 "id: %u", occ->op_id, occ->peer_id); 1292 "id: %u", occ->op_id, occ->peer->id);
1298 occ->peer->reference_cnt++;
1299 occ->cgh_ch = 1293 occ->cgh_ch =
1300 GST_cache_get_handle_core (occ->peer_id, occ->peer->details.local.cfg, 1294 GST_cache_get_handle_core (occ->peer->id, occ->peer->details.local.cfg,
1301 occ_cache_get_handle_core_cb, occ, 1295 occ_cache_get_handle_core_cb, occ,
1302 &occ->other_peer_identity, 1296 &occ->other_peer_identity,
1303 &overlay_connect_notify, occ); 1297 &overlay_connect_notify, occ);
@@ -1327,6 +1321,7 @@ cleanup_rocc (struct RemoteOverlayConnectCtx *rocc)
1327 GNUNET_SCHEDULER_cancel (rocc->tcc.task); 1321 GNUNET_SCHEDULER_cancel (rocc->tcc.task);
1328 //GNUNET_TRANSPORT_disconnect (rocc->tcc.th_); 1322 //GNUNET_TRANSPORT_disconnect (rocc->tcc.th_);
1329 GST_cache_get_handle_done (rocc->tcc.cgh_th); 1323 GST_cache_get_handle_done (rocc->tcc.cgh_th);
1324 GNUNET_assert (rocc->peer->reference_cnt > 0);
1330 rocc->peer->reference_cnt--; 1325 rocc->peer->reference_cnt--;
1331 if ((GNUNET_YES == rocc->peer->destroy_flag) && 1326 if ((GNUNET_YES == rocc->peer->destroy_flag) &&
1332 (0 == rocc->peer->reference_cnt)) 1327 (0 == rocc->peer->reference_cnt))