aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSree Harsha Totakura <totakura@in.tum.de>2013-02-01 12:51:14 +0000
committerSree Harsha Totakura <totakura@in.tum.de>2013-02-01 12:51:14 +0000
commit4d9b96f0f6c22cc90269137fccf7d04f7296504e (patch)
tree8f33504ddb23e10ba7fbf8d6a83766e467e81686 /src
parent173616fa2120be705164536d8bd391f6588da11b (diff)
downloadgnunet-4d9b96f0f6c22cc90269137fccf7d04f7296504e.tar.gz
gnunet-4d9b96f0f6c22cc90269137fccf7d04f7296504e.zip
- fixes
Diffstat (limited to 'src')
-rw-r--r--src/testbed/gnunet-service-testbed_cache.c9
-rw-r--r--src/testbed/gnunet-service-testbed_oc.c93
2 files changed, 68 insertions, 34 deletions
diff --git a/src/testbed/gnunet-service-testbed_cache.c b/src/testbed/gnunet-service-testbed_cache.c
index f91e8c9d9..c75ae7dc4 100644
--- a/src/testbed/gnunet-service-testbed_cache.c
+++ b/src/testbed/gnunet-service-testbed_cache.c
@@ -531,10 +531,11 @@ opstart_get_handle_transport (void *cls)
531 GNUNET_break (0); 531 GNUNET_break (0);
532 return; 532 return;
533 } 533 }
534 //GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == entry->notify_task);
535 if (0 == entry->demand) 534 if (0 == entry->demand)
536 return; 535 return;
537 if (GNUNET_NO == entry->cgh_qhead->notify_called) 536 if (GNUNET_SCHEDULER_NO_TASK != entry->notify_task)
537 return;
538 if (NULL != search_suitable_cgh (entry, entry->cgh_qhead))
538 entry->notify_task = GNUNET_SCHEDULER_add_now (&call_cgh_cb, entry); 539 entry->notify_task = GNUNET_SCHEDULER_add_now (&call_cgh_cb, entry);
539} 540}
540 541
@@ -588,8 +589,10 @@ core_startup_cb (void *cls,
588 memcpy (entry->peer_identity, my_identity, 589 memcpy (entry->peer_identity, my_identity,
589 sizeof (struct GNUNET_PeerIdentity)); 590 sizeof (struct GNUNET_PeerIdentity));
590 if (0 == entry->demand) 591 if (0 == entry->demand)
592 return;
593 if (GNUNET_SCHEDULER_NO_TASK != entry->notify_task)
591 return; 594 return;
592 if (GNUNET_NO == entry->cgh_qhead->notify_called) 595 if (NULL != search_suitable_cgh (entry, entry->cgh_qhead))
593 entry->notify_task = GNUNET_SCHEDULER_add_now (&call_cgh_cb, entry); 596 entry->notify_task = GNUNET_SCHEDULER_add_now (&call_cgh_cb, entry);
594} 597}
595 598
diff --git a/src/testbed/gnunet-service-testbed_oc.c b/src/testbed/gnunet-service-testbed_oc.c
index b7650e932..43841b461 100644
--- a/src/testbed/gnunet-service-testbed_oc.c
+++ b/src/testbed/gnunet-service-testbed_oc.c
@@ -107,12 +107,12 @@ struct OverlayConnectContext
107 /** 107 /**
108 * Transport handle of the first peer to get its HELLO 108 * Transport handle of the first peer to get its HELLO
109 */ 109 */
110 struct GNUNET_TRANSPORT_Handle *p1th; 110 struct GNUNET_TRANSPORT_Handle *p1th_;
111 111
112 /** 112 /**
113 * The GetCacheHandle for the p1th transport handle 113 * The CacheGetHandle for the p1th transport handle
114 */ 114 */
115 struct GSTGetCacheHandle *gch_p1th; 115 struct GSTCacheGetHandle *cgh_p1th;
116 116
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
@@ -418,9 +418,9 @@ cleanup_occ (struct OverlayConnectContext *occ)
418 GNUNET_SCHEDULER_cancel (occ->tcc.task); 418 GNUNET_SCHEDULER_cancel (occ->tcc.task);
419 if (NULL != occ->tcc.tch) 419 if (NULL != occ->tcc.tch)
420 GNUNET_TRANSPORT_try_connect_cancel (occ->tcc.tch); 420 GNUNET_TRANSPORT_try_connect_cancel (occ->tcc.tch);
421 if (NULL != occ->p1th) 421 if (NULL != occ->cgh_p1th)
422 { 422 {
423 GNUNET_TRANSPORT_disconnect (occ->p1th); 423 GST_cache_get_handle_done (occ->cgh_p1th);
424 occ->peer->reference_cnt--; 424 occ->peer->reference_cnt--;
425 } 425 }
426 if (NULL != occ->tcc.cgh_th) 426 if (NULL != occ->tcc.cgh_th)
@@ -764,7 +764,8 @@ p2_transport_connect (struct OverlayConnectContext *occ)
764 GNUNET_assert (NULL == occ->emsg); 764 GNUNET_assert (NULL == occ->emsg);
765 GNUNET_assert (NULL != occ->hello); 765 GNUNET_assert (NULL != occ->hello);
766 GNUNET_assert (NULL == occ->ghh); 766 GNUNET_assert (NULL == occ->ghh);
767 GNUNET_assert (NULL == occ->p1th); 767 GNUNET_assert (NULL == occ->p1th_);
768 GNUNET_assert (NULL == occ->cgh_p1th);
768 if (NULL == occ->peer2_controller) 769 if (NULL == occ->peer2_controller)
769 { 770 {
770 GST_peer_list[occ->other_peer_id]->reference_cnt++; 771 GST_peer_list[occ->other_peer_id]->reference_cnt++;
@@ -835,9 +836,10 @@ hello_update_cb (void *cls, const struct GNUNET_MessageHeader *hello)
835 memcpy (occ->hello, hello, msize); 836 memcpy (occ->hello, hello, msize);
836 GNUNET_TRANSPORT_get_hello_cancel (occ->ghh); 837 GNUNET_TRANSPORT_get_hello_cancel (occ->ghh);
837 occ->ghh = NULL; 838 occ->ghh = NULL;
838 GNUNET_TRANSPORT_disconnect (occ->p1th); 839 GST_cache_get_handle_done (occ->cgh_p1th);
839 occ->p1th = NULL;
840 occ->peer->reference_cnt--; 840 occ->peer->reference_cnt--;
841 occ->cgh_p1th = NULL;
842 occ->p1th_ = NULL;
841 GNUNET_free_non_null (occ->emsg); 843 GNUNET_free_non_null (occ->emsg);
842 occ->emsg = NULL; 844 occ->emsg = NULL;
843 p2_transport_connect (occ); 845 p2_transport_connect (occ);
@@ -850,6 +852,42 @@ hello_update_cb (void *cls, const struct GNUNET_MessageHeader *hello)
850 * @param cls the closure passed to GST_cache_get_handle_transport() 852 * @param cls the closure passed to GST_cache_get_handle_transport()
851 * @param ch the handle to CORE. Can be NULL if it is not requested 853 * @param ch the handle to CORE. Can be NULL if it is not requested
852 * @param th the handle to TRANSPORT. Can be NULL if it is not requested 854 * @param th the handle to TRANSPORT. Can be NULL if it is not requested
855 * @param ignore_ peer identity which is ignored in this callback
856 */
857static void
858p1_transport_connect_cache_callback (void *cls, struct GNUNET_CORE_Handle *ch,
859 struct GNUNET_TRANSPORT_Handle *th,
860 const struct GNUNET_PeerIdentity *ignore_)
861{
862 struct OverlayConnectContext *occ = cls;
863
864 GNUNET_free_non_null (occ->emsg);
865 occ->emsg = NULL;
866 if (NULL == th)
867 {
868 GNUNET_asprintf (&occ->emsg, "0x%llx: Cannot connect to TRANSPORT of %s",
869 occ->op_id, GNUNET_i2s (&occ->peer_identity));
870 GNUNET_SCHEDULER_cancel (occ->timeout_task);
871 occ->timeout_task =
872 GNUNET_SCHEDULER_add_now (&timeout_overlay_connect, occ);
873 return;
874 }
875 GNUNET_assert (NULL == occ->p1th_);
876 GNUNET_assert (NULL != occ->cgh_p1th);
877 occ->p1th_ = th;
878 GNUNET_asprintf (&occ->emsg,
879 "0x%llx: Timeout while acquiring HELLO of peer %4s",
880 occ->op_id, GNUNET_i2s (&occ->peer_identity));
881 occ->ghh = GNUNET_TRANSPORT_get_hello (occ->p1th_, &hello_update_cb, occ);
882}
883
884
885/**
886 * Callback from cache with needed handles set
887 *
888 * @param cls the closure passed to GST_cache_get_handle_transport()
889 * @param ch the handle to CORE. Can be NULL if it is not requested
890 * @param th the handle to TRANSPORT. Can be NULL if it is not requested
853 * @param my_identity the identity of our peer 891 * @param my_identity the identity of our peer
854 */ 892 */
855static void 893static void
@@ -862,12 +900,15 @@ occ_cache_get_handle_core_cb (void *cls, struct GNUNET_CORE_Handle *ch,
862 900
863 GNUNET_assert (GNUNET_SCHEDULER_NO_TASK != occ->timeout_task); 901 GNUNET_assert (GNUNET_SCHEDULER_NO_TASK != occ->timeout_task);
864 GNUNET_free_non_null (occ->emsg); 902 GNUNET_free_non_null (occ->emsg);
865 (void) GNUNET_asprintf (&occ->emsg,
866 "0x%llx: Failed to connect to CORE of peer with"
867 "id: %u", occ->op_id, occ->peer_id);
868 if ((NULL == ch) || (NULL == my_identity)) 903 if ((NULL == ch) || (NULL == my_identity))
869 goto error_return; 904 {
870 GNUNET_free (occ->emsg); 905 (void) GNUNET_asprintf (&occ->emsg,
906 "0x%llx: Failed to connect to CORE of peer with"
907 "id: %u", occ->op_id, occ->peer_id);
908 GNUNET_SCHEDULER_cancel (occ->timeout_task);
909 occ->timeout_task = GNUNET_SCHEDULER_add_now (&timeout_overlay_connect, occ);
910 return;
911 }
871 //occ->ch_ = ch; 912 //occ->ch_ = ch;
872 occ->emsg = NULL; 913 occ->emsg = NULL;
873 if (GNUNET_YES == 914 if (GNUNET_YES ==
@@ -893,26 +934,16 @@ occ_cache_get_handle_core_cb (void *cls, struct GNUNET_CORE_Handle *ch,
893 p2_transport_connect (occ); 934 p2_transport_connect (occ);
894 return; 935 return;
895 } 936 }
896 occ->peer->reference_cnt++;
897 occ->p1th =
898 GNUNET_TRANSPORT_connect (occ->peer->details.local.cfg,
899 &occ->peer_identity, NULL, NULL, NULL, NULL);
900 if (NULL == occ->p1th)
901 {
902 GNUNET_asprintf (&occ->emsg,
903 "0x%llx: Cannot connect to TRANSPORT of peer %4s",
904 occ->op_id, GNUNET_i2s (&occ->peer_identity));
905 goto error_return;
906 }
907 GNUNET_asprintf (&occ->emsg, 937 GNUNET_asprintf (&occ->emsg,
908 "0x%llx: Timeout while acquiring HELLO of peer %4s", 938 "0x%llx: Timeout while acquiring TRANSPORT of %s from cache",
909 occ->op_id, GNUNET_i2s (&occ->peer_identity)); 939 occ->op_id, GNUNET_i2s (&occ->peer_identity));
910 occ->ghh = GNUNET_TRANSPORT_get_hello (occ->p1th, &hello_update_cb, occ); 940 occ->peer->reference_cnt++;
911 return; 941 occ->cgh_p1th =
912 942 GST_cache_get_handle_transport (occ->peer_id,
913error_return: 943 occ->peer->details.local.cfg,
914 GNUNET_SCHEDULER_cancel (occ->timeout_task); 944 p1_transport_connect_cache_callback,
915 occ->timeout_task = GNUNET_SCHEDULER_add_now (&timeout_overlay_connect, occ); 945 occ,
946 NULL, NULL, NULL);
916 return; 947 return;
917} 948}
918 949