aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSree Harsha Totakura <totakura@in.tum.de>2013-01-31 20:02:50 +0000
committerSree Harsha Totakura <totakura@in.tum.de>2013-01-31 20:02:50 +0000
commit2d8f5e4d85f96c131948c061d2375efe9e783f87 (patch)
treee91a3ca6fe9f66b471547397302e121ceec1cd0d /src
parent61a895198882629e1bf1632a640eb876202067a0 (diff)
downloadgnunet-2d8f5e4d85f96c131948c061d2375efe9e783f87.tar.gz
gnunet-2d8f5e4d85f96c131948c061d2375efe9e783f87.zip
- fixes and implements caching core handles
Diffstat (limited to 'src')
-rw-r--r--src/testbed/gnunet-service-testbed_hc.c86
-rw-r--r--src/testbed/gnunet-service-testbed_oc.c196
2 files changed, 116 insertions, 166 deletions
diff --git a/src/testbed/gnunet-service-testbed_hc.c b/src/testbed/gnunet-service-testbed_hc.c
index 9d50ae257..6a75bbc79 100644
--- a/src/testbed/gnunet-service-testbed_hc.c
+++ b/src/testbed/gnunet-service-testbed_hc.c
@@ -296,25 +296,6 @@ cache_lookup (const struct GNUNET_HashCode *key)
296} 296}
297 297
298 298
299static struct CacheEntry *
300cache_lookup_handles (const struct GNUNET_HashCode *pid,
301 struct GNUNET_TRANSPORT_Handle **th,
302 struct GNUNET_CORE_Handle **ch)
303{
304 struct CacheEntry *entry;
305
306 GNUNET_assert ((NULL != th) || (NULL != ch));
307 entry = cache_lookup (pid);
308 if (NULL == entry)
309 return NULL;
310 if ((NULL != entry->transport_handle_) && (NULL != th))
311 *th = entry->transport_handle_;
312 if ((NULL != entry->core_handle) && (NULL != ch))
313 *ch = entry->core_handle;
314 return entry;
315}
316
317
318static void 299static void
319cache_remove (struct CacheEntry *entry) 300cache_remove (struct CacheEntry *entry)
320{ 301{
@@ -418,6 +399,7 @@ call_cgh_cb (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
418 GNUNET_CONTAINER_DLL_insert_tail (entry->cgh_qhead, entry->cgh_qtail, cgh); 399 GNUNET_CONTAINER_DLL_insert_tail (entry->cgh_qhead, entry->cgh_qtail, cgh);
419 if (NULL != cgh2) 400 if (NULL != cgh2)
420 entry->notify_task = GNUNET_SCHEDULER_add_now (&call_cgh_cb, entry); 401 entry->notify_task = GNUNET_SCHEDULER_add_now (&call_cgh_cb, entry);
402 LOG_DEBUG ("Calling notify for handle type %u\n", cgh->type);
421 cgh->cb (cgh->cb_cls, entry->core_handle, 403 cgh->cb (cgh->cb_cls, entry->core_handle,
422 entry->transport_handle_, entry->peer_identity); 404 entry->transport_handle_, entry->peer_identity);
423} 405}
@@ -437,26 +419,36 @@ peer_connect_notify_cb (void *cls,
437{ 419{
438 struct CacheEntry *entry = cls; 420 struct CacheEntry *entry = cls;
439 struct ConnectNotifyContext *ctxt; 421 struct ConnectNotifyContext *ctxt;
422 struct ConnectNotifyContext *ctxt2;
440 GST_cache_peer_connect_notify cb; 423 GST_cache_peer_connect_notify cb;
441 void *cb_cls; 424 void *cb_cls;
442 425
443 426
444 for (ctxt=entry->nctxt_qhead; NULL != ctxt; ctxt=ctxt->next) 427 for (ctxt=entry->nctxt_qhead; NULL != ctxt;)
445 { 428 {
446 GNUNET_assert (NULL != ctxt->cgh); 429 GNUNET_assert (NULL != ctxt->cgh);
447 if (type != ctxt->cgh->type) 430 if (type != ctxt->cgh->type)
431 {
432 ctxt = ctxt->next;
448 continue; 433 continue;
449 if (0 == memcmp (ctxt->target, peer, sizeof (struct GNUNET_PeerIdentity))) 434 }
450 break; 435 if (0 != memcmp (ctxt->target, peer, sizeof (struct GNUNET_PeerIdentity)))
436 {
437 ctxt = ctxt->next;
438 continue;
439 }
440 cb = ctxt->cb;
441 cb_cls = ctxt->cb_cls;
442 ctxt->cgh->nctxt = NULL;
443 ctxt2 = ctxt->next;
444 GNUNET_CONTAINER_DLL_remove (entry->nctxt_qhead, entry->nctxt_qtail, ctxt);
445 GNUNET_free (ctxt);
446 ctxt = ctxt2;
447 cb (cb_cls, peer);
451 } 448 }
452 if (NULL == ctxt) 449 if (NULL == ctxt)
453 return; 450 return;
454 cb = ctxt->cb; 451
455 cb_cls = ctxt->cb_cls;
456 ctxt->cgh->nctxt = NULL;
457 GNUNET_CONTAINER_DLL_remove (entry->nctxt_qhead, entry->nctxt_qtail, ctxt);
458 GNUNET_free (ctxt);
459 cb (cb_cls, peer);
460} 452}
461 453
462 454
@@ -592,11 +584,6 @@ opstart_get_handle_core (void *cls)
592 NULL, /* outbound notify */ 584 NULL, /* outbound notify */
593 GNUNET_NO, 585 GNUNET_NO,
594 no_handlers); 586 no_handlers);
595 if (NULL == entry->core_handle)
596 {
597 GNUNET_break (0);
598 return;
599 }
600 //GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == entry->notify_task); 587 //GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == entry->notify_task);
601} 588}
602 589
@@ -632,31 +619,28 @@ cache_get_handle (unsigned int peer_id,
632 GNUNET_assert (0 != cgh->type); 619 GNUNET_assert (0 != cgh->type);
633 GNUNET_CRYPTO_hash (&peer_id, sizeof (peer_id), &key); 620 GNUNET_CRYPTO_hash (&peer_id, sizeof (peer_id), &key);
634 handle = NULL; 621 handle = NULL;
635 entry = NULL; 622 entry = cache_lookup (&key);
636 switch (cgh->type) 623 if (NULL != entry)
637 {
638 case CGT_TRANSPORT_HANDLE:
639 entry = cache_lookup_handles (&key, (struct GNUNET_TRANSPORT_Handle **)
640 &handle, NULL);
641 if (NULL != handle)
642 LOG_DEBUG ("Found TRANSPORT handle in cache for peer %u\n", entry->peer_id);
643 break;
644 case CGT_CORE_HANDLE:
645 entry = cache_lookup_handles (&key, NULL,
646 (struct GNUNET_CORE_Handle **) &handle);
647 if (NULL != handle)
648 LOG_DEBUG ("Found CORE handle in cache for peer %u\n", entry->peer_id);
649 break;
650 }
651 if (NULL != handle)
652 { 624 {
653 GNUNET_assert (NULL != entry);
654 if (0 == entry->demand) 625 if (0 == entry->demand)
655 { 626 {
656 GNUNET_assert (0 < lru_cache_size); 627 GNUNET_assert (0 < lru_cache_size);
657 GNUNET_CONTAINER_DLL_remove (lru_cache_head, lru_cache_tail, entry); 628 GNUNET_CONTAINER_DLL_remove (lru_cache_head, lru_cache_tail, entry);
658 lru_cache_size--; 629 lru_cache_size--;
659 } 630 }
631 switch (cgh->type)
632 {
633 case CGT_TRANSPORT_HANDLE:
634 handle = entry->transport_handle_;
635 if (NULL != handle)
636 LOG_DEBUG ("Found TRANSPORT handle in cache for peer %u\n", entry->peer_id);
637 break;
638 case CGT_CORE_HANDLE:
639 handle = entry->core_handle;
640 if (NULL != handle)
641 LOG_DEBUG ("Found CORE handle in cache for peer %u\n", entry->peer_id);
642 break;
643 }
660 } 644 }
661 if (NULL == entry) 645 if (NULL == entry)
662 entry = add_entry (&key, peer_id); 646 entry = add_entry (&key, peer_id);
diff --git a/src/testbed/gnunet-service-testbed_oc.c b/src/testbed/gnunet-service-testbed_oc.c
index de6e53031..ddc31e5e2 100644
--- a/src/testbed/gnunet-service-testbed_oc.c
+++ b/src/testbed/gnunet-service-testbed_oc.c
@@ -117,7 +117,12 @@ struct OverlayConnectContext
117 /** 117 /**
118 * Core handles of the first peer; used to notify when second peer connects to it 118 * Core handles of the first peer; used to notify when second peer connects to it
119 */ 119 */
120 struct GNUNET_CORE_Handle *ch; 120 //struct GNUNET_CORE_Handle *ch_;
121
122 /**
123 * The GetCacheHandle for the p1th transport handle
124 */
125 struct GSTCacheGetHandle *cgh_ch;
121 126
122 /** 127 /**
123 * HELLO of the other peer 128 * HELLO of the other peer
@@ -145,11 +150,6 @@ struct OverlayConnectContext
145 struct OperationContext *opc; 150 struct OperationContext *opc;
146 151
147 /** 152 /**
148 * The local operation we create for this overlay connection
149 */
150 struct GNUNET_TESTBED_Operation *lop;
151
152 /**
153 * Controller of peer 2; NULL if the peer is local 153 * Controller of peer 2; NULL if the peer is local
154 */ 154 */
155 struct GNUNET_TESTBED_Controller *peer2_controller; 155 struct GNUNET_TESTBED_Controller *peer2_controller;
@@ -393,11 +393,6 @@ GST_process_next_focc (struct RegisteredHostContext *rhc)
393static void 393static void
394cleanup_occ (struct OverlayConnectContext *occ) 394cleanup_occ (struct OverlayConnectContext *occ)
395{ 395{
396 if (NULL != occ->lop)
397 {
398 GNUNET_TESTBED_operation_release_ (occ->lop);
399 return;
400 }
401 LOG_DEBUG ("0x%llx: Cleaning up occ\n", occ->op_id); 396 LOG_DEBUG ("0x%llx: Cleaning up occ\n", occ->op_id);
402 GNUNET_free_non_null (occ->emsg); 397 GNUNET_free_non_null (occ->emsg);
403 GNUNET_free_non_null (occ->hello); 398 GNUNET_free_non_null (occ->hello);
@@ -410,9 +405,9 @@ cleanup_occ (struct OverlayConnectContext *occ)
410 GNUNET_SCHEDULER_cancel (occ->cleanup_task); 405 GNUNET_SCHEDULER_cancel (occ->cleanup_task);
411 if (GNUNET_SCHEDULER_NO_TASK != occ->timeout_task) 406 if (GNUNET_SCHEDULER_NO_TASK != occ->timeout_task)
412 GNUNET_SCHEDULER_cancel (occ->timeout_task); 407 GNUNET_SCHEDULER_cancel (occ->timeout_task);
413 if (NULL != occ->ch) 408 if (NULL != occ->cgh_ch)
414 { 409 {
415 GNUNET_CORE_disconnect (occ->ch); 410 GST_cache_get_handle_done (occ->cgh_ch);
416 occ->peer->reference_cnt--; 411 occ->peer->reference_cnt--;
417 } 412 }
418 if (NULL != occ->ghh) 413 if (NULL != occ->ghh)
@@ -441,7 +436,6 @@ cleanup_occ (struct OverlayConnectContext *occ)
441 (0 == GST_peer_list[occ->other_peer_id]->reference_cnt)) 436 (0 == GST_peer_list[occ->other_peer_id]->reference_cnt))
442 GST_destroy_peer (GST_peer_list[occ->other_peer_id]); 437 GST_destroy_peer (GST_peer_list[occ->other_peer_id]);
443 GNUNET_CONTAINER_DLL_remove (occq_head, occq_tail, occ); 438 GNUNET_CONTAINER_DLL_remove (occq_head, occq_tail, occ);
444 GNUNET_assert (NULL == occ->lop);
445 GNUNET_free (occ); 439 GNUNET_free (occ);
446} 440}
447 441
@@ -484,22 +478,37 @@ timeout_overlay_connect (void *cls,
484} 478}
485 479
486 480
481static void
482send_overlay_connect_success_msg (struct OverlayConnectContext *occ)
483{
484 struct GNUNET_TESTBED_ConnectionEventMessage *msg;
485
486 LOG_DEBUG ("0x%llx: Peers connected - Sending overlay connect success\n",
487 occ->op_id);
488 msg = GNUNET_malloc (sizeof (struct GNUNET_TESTBED_ConnectionEventMessage));
489 msg->header.size =
490 htons (sizeof (struct GNUNET_TESTBED_ConnectionEventMessage));
491 msg->header.type = htons (GNUNET_MESSAGE_TYPE_TESTBED_PEER_CONNECT_EVENT);
492 msg->event_type = htonl (GNUNET_TESTBED_ET_CONNECT);
493 msg->peer1 = htonl (occ->peer_id);
494 msg->peer2 = htonl (occ->other_peer_id);
495 msg->operation_id = GNUNET_htonll (occ->op_id);
496 GST_queue_message (occ->client, &msg->header);
497}
498
499
487/** 500/**
488 * Function called to notify transport users that another 501 * Function called to notify transport users that another
489 * peer connected to us. 502 * peer connected to us.
490 * 503 *
491 * @param cls closure 504 * @param cls closure
492 * @param new_peer the peer that connected 505 * @param new_peer the peer that connected
493 * @param ats performance data
494 * @param ats_count number of entries in ats (excluding 0-termination)
495 */ 506 */
496static void 507static void
497overlay_connect_notify (void *cls, const struct GNUNET_PeerIdentity *new_peer, 508overlay_connect_notify (void *cls,
498 const struct GNUNET_ATS_Information *ats, 509 const struct GNUNET_PeerIdentity *new_peer)
499 unsigned int ats_count)
500{ 510{
501 struct OverlayConnectContext *occ = cls; 511 struct OverlayConnectContext *occ = cls;
502 struct GNUNET_TESTBED_ConnectionEventMessage *msg;
503 char *new_peer_str; 512 char *new_peer_str;
504 char *other_peer_str; 513 char *other_peer_str;
505 514
@@ -537,19 +546,12 @@ overlay_connect_notify (void *cls, const struct GNUNET_PeerIdentity *new_peer,
537 GNUNET_SCHEDULER_cancel (occ->tcc.task); 546 GNUNET_SCHEDULER_cancel (occ->tcc.task);
538 occ->tcc.task = GNUNET_SCHEDULER_NO_TASK; 547 occ->tcc.task = GNUNET_SCHEDULER_NO_TASK;
539 } 548 }
549 GST_cache_get_handle_done (occ->cgh_ch);
550 occ->peer->reference_cnt--;
551 occ->cgh_ch = NULL;
540 GNUNET_free_non_null (occ->emsg); 552 GNUNET_free_non_null (occ->emsg);
541 occ->emsg = NULL; 553 occ->emsg = NULL;
542 LOG_DEBUG ("0x%llx: Peers connected - Sending overlay connect success\n", 554 send_overlay_connect_success_msg (occ);
543 occ->op_id);
544 msg = GNUNET_malloc (sizeof (struct GNUNET_TESTBED_ConnectionEventMessage));
545 msg->header.size =
546 htons (sizeof (struct GNUNET_TESTBED_ConnectionEventMessage));
547 msg->header.type = htons (GNUNET_MESSAGE_TYPE_TESTBED_PEER_CONNECT_EVENT);
548 msg->event_type = htonl (GNUNET_TESTBED_ET_CONNECT);
549 msg->peer1 = htonl (occ->peer_id);
550 msg->peer2 = htonl (occ->other_peer_id);
551 msg->operation_id = GNUNET_htonll (occ->op_id);
552 GST_queue_message (occ->client, &msg->header);
553 occ->cleanup_task = GNUNET_SCHEDULER_add_now (&do_cleanup_occ, occ); 555 occ->cleanup_task = GNUNET_SCHEDULER_add_now (&do_cleanup_occ, occ);
554 //cleanup_occ (occ); 556 //cleanup_occ (occ);
555} 557}
@@ -846,32 +848,41 @@ hello_update_cb (void *cls, const struct GNUNET_MessageHeader *hello)
846 848
847 849
848/** 850/**
849 * Function called after GNUNET_CORE_connect has succeeded (or failed 851 * Callback from cache with needed handles set
850 * for good). Note that the private key of the peer is intentionally
851 * not exposed here; if you need it, your process should try to read
852 * the private key file directly (which should work if you are
853 * authorized...).
854 * 852 *
855 * @param cls closure 853 * @param cls the closure passed to GST_cache_get_handle_transport()
856 * @param server handle to the server, NULL if we failed 854 * @param ch the handle to CORE. Can be NULL if it is not requested
857 * @param my_identity ID of this peer, NULL if we failed 855 * @param th the handle to TRANSPORT. Can be NULL if it is not requested
856 * @param my_identity the identity of our peer
858 */ 857 */
859static void 858static void
860core_startup_cb (void *cls, struct GNUNET_CORE_Handle *server, 859occ_cache_get_handle_core_cb (void *cls, struct GNUNET_CORE_Handle *ch,
861 const struct GNUNET_PeerIdentity *my_identity) 860 struct GNUNET_TRANSPORT_Handle *th,
861 const struct GNUNET_PeerIdentity *my_identity)
862{ 862{
863 struct OverlayConnectContext *occ = cls; 863 struct OverlayConnectContext *occ = cls;
864 const struct GNUNET_MessageHeader *hello; 864 const struct GNUNET_MessageHeader *hello;
865 865
866 GNUNET_assert (GNUNET_SCHEDULER_NO_TASK != occ->timeout_task);
866 GNUNET_free_non_null (occ->emsg); 867 GNUNET_free_non_null (occ->emsg);
867 (void) GNUNET_asprintf (&occ->emsg, 868 (void) GNUNET_asprintf (&occ->emsg,
868 "0x%llx: Failed to connect to CORE of peer with" 869 "0x%llx: Failed to connect to CORE of peer with"
869 "id: %u", occ->op_id, occ->peer_id); 870 "id: %u", occ->op_id, occ->peer_id);
870 if ((NULL == server) || (NULL == my_identity)) 871 if ((NULL == ch) || (NULL == my_identity))
871 goto error_return; 872 goto error_return;
872 GNUNET_free (occ->emsg); 873 GNUNET_free (occ->emsg);
873 occ->ch = server; 874 //occ->ch_ = ch;
874 occ->emsg = NULL; 875 occ->emsg = NULL;
876 if (GNUNET_YES ==
877 GNUNET_CORE_is_peer_connected_sync (ch, &occ->other_peer_identity))
878 {
879 LOG_DEBUG ("0x%llx: Target peer already connected\n", occ->op_id);
880 GNUNET_SCHEDULER_cancel (occ->timeout_task);
881 occ->timeout_task = GNUNET_SCHEDULER_NO_TASK;
882 send_overlay_connect_success_msg (occ);
883 occ->cleanup_task = GNUNET_SCHEDULER_add_now (&do_cleanup_occ, occ);
884 return;
885 }
875 memcpy (&occ->peer_identity, my_identity, 886 memcpy (&occ->peer_identity, my_identity,
876 sizeof (struct GNUNET_PeerIdentity)); 887 sizeof (struct GNUNET_PeerIdentity));
877 LOG_DEBUG ("0x%llx: Acquiring HELLO of peer %s\n", occ->op_id, 888 LOG_DEBUG ("0x%llx: Acquiring HELLO of peer %s\n", occ->op_id,
@@ -910,58 +921,6 @@ error_return:
910 921
911 922
912/** 923/**
913 * Callback which will be called when overlay connect operation is started
914 *
915 * @param cls the closure from GNUNET_TESTBED_operation_create_()
916 */
917static void
918opstart_overlay_connect (void *cls)
919{
920 struct OverlayConnectContext *occ = cls;
921
922 const struct GNUNET_CORE_MessageHandler no_handlers[] = {
923 {NULL, 0, 0}
924 };
925
926 GNUNET_assert (NULL != occ->lop);
927 /* Connect to the core of 1st peer and wait for the 2nd peer to connect */
928 occ->emsg = GNUNET_strdup ("Timeout while connecting to CORE");
929 GNUNET_asprintf (&occ->emsg,
930 "0x%llx: Timeout while connecting to CORE of peer with "
931 "id: %u", occ->op_id, occ->peer_id);
932 occ->peer->reference_cnt++;
933 occ->ch =
934 GNUNET_CORE_connect (occ->peer->details.local.cfg, occ, &core_startup_cb,
935 &overlay_connect_notify, NULL, NULL, GNUNET_NO, NULL,
936 GNUNET_NO, no_handlers);
937 if (GNUNET_SCHEDULER_NO_TASK != occ->timeout_task)
938 GNUNET_SCHEDULER_cancel (occ->timeout_task);
939 if (NULL == occ->ch)
940 occ->timeout_task =
941 GNUNET_SCHEDULER_add_now (&timeout_overlay_connect, occ);
942 else
943 occ->timeout_task =
944 GNUNET_SCHEDULER_add_delayed (TIMEOUT, &timeout_overlay_connect, occ);
945}
946
947
948/**
949 * Callback which will be called when overlay connect operation is released
950 *
951 * @param cls the closure from GNUNET_TESTBED_operation_create_()
952 */
953static void
954oprelease_overlay_connect (void *cls)
955{
956 struct OverlayConnectContext *occ = cls;
957
958 GNUNET_assert (NULL != occ->lop);
959 occ->lop = NULL;
960 cleanup_occ (occ);
961}
962
963
964/**
965 * Callback to be called when forwarded get peer config operation as part of 924 * Callback to be called when forwarded get peer config operation as part of
966 * overlay connect is successfull. Connection to Peer 1's core is made and is 925 * overlay connect is successfull. Connection to Peer 1's core is made and is
967 * checked for new connection from peer 2 926 * checked for new connection from peer 2
@@ -976,6 +935,7 @@ overlay_connect_get_config (void *cls, const struct GNUNET_MessageHeader *msg)
976 const struct GNUNET_TESTBED_PeerConfigurationInformationMessage *cmsg; 935 const struct GNUNET_TESTBED_PeerConfigurationInformationMessage *cmsg;
977 936
978 occ->opc = NULL; 937 occ->opc = NULL;
938 GNUNET_assert (GNUNET_SCHEDULER_NO_TASK != occ->timeout_task);
979 if (GNUNET_MESSAGE_TYPE_TESTBED_PEER_CONFIGURATION != ntohs (msg->type)) 939 if (GNUNET_MESSAGE_TYPE_TESTBED_PEER_CONFIGURATION != ntohs (msg->type))
980 { 940 {
981 GNUNET_SCHEDULER_cancel (occ->timeout_task); 941 GNUNET_SCHEDULER_cancel (occ->timeout_task);
@@ -987,15 +947,17 @@ overlay_connect_get_config (void *cls, const struct GNUNET_MessageHeader *msg)
987 memcpy (&occ->other_peer_identity, &cmsg->peer_identity, 947 memcpy (&occ->other_peer_identity, &cmsg->peer_identity,
988 sizeof (struct GNUNET_PeerIdentity)); 948 sizeof (struct GNUNET_PeerIdentity));
989 GNUNET_free_non_null (occ->emsg); 949 GNUNET_free_non_null (occ->emsg);
990 occ->emsg = NULL; 950 GNUNET_asprintf (&occ->emsg,
991 GNUNET_assert (NULL == occ->lop); 951 "0x%llx: Timeout while connecting to CORE of peer with "
992 occ->lop = 952 "id: %u", occ->op_id, occ->peer_id);
993 GNUNET_TESTBED_operation_create_ (occ, &opstart_overlay_connect, 953 occ->peer->reference_cnt++;
994 &oprelease_overlay_connect); 954 occ->cgh_ch = GST_cache_get_handle_core (occ->peer_id,
995 /* This operation needs in total 2 connections (one to core and one to 955 occ->peer->details.local.cfg,
996 * transport) */ 956 occ_cache_get_handle_core_cb,
997 GNUNET_TESTBED_operation_queue_insert2_ (GST_opq_openfds, occ->lop, 2); 957 occ,
998 GNUNET_TESTBED_operation_begin_wait_ (occ->lop); 958 &occ->other_peer_identity,
959 &overlay_connect_notify,
960 occ);
999 return; 961 return;
1000} 962}
1001 963
@@ -1274,6 +1236,9 @@ GST_handle_overlay_connect (void *cls, struct GNUNET_SERVER_Client *client,
1274 occ->peer = GST_peer_list[p1]; 1236 occ->peer = GST_peer_list[p1];
1275 occ->op_id = GNUNET_ntohll (msg->operation_id); 1237 occ->op_id = GNUNET_ntohll (msg->operation_id);
1276 occ->peer2_controller = peer2_controller; 1238 occ->peer2_controller = peer2_controller;
1239 GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == occ->timeout_task);
1240 occ->timeout_task =
1241 GNUNET_SCHEDULER_add_delayed (TIMEOUT, &timeout_overlay_connect, occ);
1277 /* Get the identity of the second peer */ 1242 /* Get the identity of the second peer */
1278 if (NULL != occ->peer2_controller) 1243 if (NULL != occ->peer2_controller)
1279 { 1244 {
@@ -1293,22 +1258,23 @@ GST_handle_overlay_connect (void *cls, struct GNUNET_SERVER_Client *client,
1293 GNUNET_asprintf (&occ->emsg, 1258 GNUNET_asprintf (&occ->emsg,
1294 "0x%llx: Timeout while getting peer identity of peer " 1259 "0x%llx: Timeout while getting peer identity of peer "
1295 "with id: %u", occ->op_id, occ->other_peer_id); 1260 "with id: %u", occ->op_id, occ->other_peer_id);
1296 GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == occ->timeout_task);
1297 occ->timeout_task =
1298 GNUNET_SCHEDULER_add_delayed (TIMEOUT, &timeout_overlay_connect, occ);
1299 GNUNET_SERVER_receive_done (client, GNUNET_OK); 1261 GNUNET_SERVER_receive_done (client, GNUNET_OK);
1300 return; 1262 return;
1301 } 1263 }
1302 GNUNET_TESTING_peer_get_identity (GST_peer_list[occ->other_peer_id]-> 1264 GNUNET_TESTING_peer_get_identity (GST_peer_list[occ->other_peer_id]->
1303 details.local.peer, 1265 details.local.peer,
1304 &occ->other_peer_identity); 1266 &occ->other_peer_identity);
1305 occ->lop = 1267 GNUNET_asprintf (&occ->emsg,
1306 GNUNET_TESTBED_operation_create_ (occ, &opstart_overlay_connect, 1268 "0x%llx: Timeout while connecting to CORE of peer with "
1307 &oprelease_overlay_connect); 1269 "id: %u", occ->op_id, occ->peer_id);
1308 /* This operation needs in total 2 connections (one to core and one to 1270 occ->peer->reference_cnt++;
1309 * transport) */ 1271 occ->cgh_ch = GST_cache_get_handle_core (occ->peer_id,
1310 GNUNET_TESTBED_operation_queue_insert2_ (GST_opq_openfds, occ->lop, 2); 1272 occ->peer->details.local.cfg,
1311 GNUNET_TESTBED_operation_begin_wait_ (occ->lop); 1273 occ_cache_get_handle_core_cb,
1274 occ,
1275 &occ->other_peer_identity,
1276 &overlay_connect_notify,
1277 occ);
1312 GNUNET_SERVER_receive_done (client, GNUNET_OK); 1278 GNUNET_SERVER_receive_done (client, GNUNET_OK);
1313} 1279}
1314 1280