diff options
author | Sree Harsha Totakura <totakura@in.tum.de> | 2013-01-30 10:41:18 +0000 |
---|---|---|
committer | Sree Harsha Totakura <totakura@in.tum.de> | 2013-01-30 10:41:18 +0000 |
commit | fba943e3277c68b7212e4803e934f2f301a2b356 (patch) | |
tree | 8025d3196f9c6833ec6c8e695495271d2f7c1613 /src | |
parent | 105e00be9252a2e6db0dec566b2b0d9e633a31bf (diff) | |
download | gnunet-fba943e3277c68b7212e4803e934f2f301a2b356.tar.gz gnunet-fba943e3277c68b7212e4803e934f2f301a2b356.zip |
- fixes
Diffstat (limited to 'src')
-rw-r--r-- | src/testbed/gnunet-service-testbed_hc.c | 74 | ||||
-rw-r--r-- | src/testbed/gnunet-service-testbed_oc.c | 18 |
2 files changed, 66 insertions, 26 deletions
diff --git a/src/testbed/gnunet-service-testbed_hc.c b/src/testbed/gnunet-service-testbed_hc.c index 2f3586c45..7ca276589 100644 --- a/src/testbed/gnunet-service-testbed_hc.c +++ b/src/testbed/gnunet-service-testbed_hc.c | |||
@@ -26,37 +26,17 @@ | |||
26 | 26 | ||
27 | #include "gnunet-service-testbed.h" | 27 | #include "gnunet-service-testbed.h" |
28 | 28 | ||
29 | 29 | /** | |
30 | * Redefine LOG with a changed log component string | ||
31 | */ | ||
30 | #ifdef LOG | 32 | #ifdef LOG |
31 | #undef LOG | 33 | #undef LOG |
32 | #endif | 34 | #endif |
33 | |||
34 | #define LOG(kind,...) \ | 35 | #define LOG(kind,...) \ |
35 | GNUNET_log_from (kind, "testbed-cache", __VA_ARGS__) | 36 | GNUNET_log_from (kind, "testbed-cache", __VA_ARGS__) |
36 | 37 | ||
37 | 38 | ||
38 | enum CacheGetType | 39 | struct GSTCacheGetHandle; |
39 | { | ||
40 | CGT_TRANSPORT_HANDLE = 1 | ||
41 | }; | ||
42 | |||
43 | |||
44 | struct GSTCacheGetHandle | ||
45 | { | ||
46 | struct GSTCacheGetHandle *next; | ||
47 | |||
48 | struct GSTCacheGetHandle *prev; | ||
49 | |||
50 | struct CacheEntry *entry; | ||
51 | |||
52 | GST_cache_callback cb; | ||
53 | |||
54 | void *cb_cls; | ||
55 | |||
56 | enum CacheGetType type; | ||
57 | |||
58 | int notify_called; | ||
59 | }; | ||
60 | 40 | ||
61 | 41 | ||
62 | /** | 42 | /** |
@@ -90,6 +70,37 @@ struct ConnectNotifyContext | |||
90 | * The closure for the notify callback | 70 | * The closure for the notify callback |
91 | */ | 71 | */ |
92 | void *cb_cls; | 72 | void *cb_cls; |
73 | |||
74 | /** | ||
75 | * The GSTCacheGetHandle reposible for creating this context | ||
76 | */ | ||
77 | struct GSTCacheGetHandle *cgh; | ||
78 | }; | ||
79 | |||
80 | |||
81 | enum CacheGetType | ||
82 | { | ||
83 | CGT_TRANSPORT_HANDLE = 1 | ||
84 | }; | ||
85 | |||
86 | |||
87 | struct GSTCacheGetHandle | ||
88 | { | ||
89 | struct GSTCacheGetHandle *next; | ||
90 | |||
91 | struct GSTCacheGetHandle *prev; | ||
92 | |||
93 | struct CacheEntry *entry; | ||
94 | |||
95 | GST_cache_callback cb; | ||
96 | |||
97 | void *cb_cls; | ||
98 | |||
99 | struct ConnectNotifyContext *nctxt; | ||
100 | |||
101 | enum CacheGetType type; | ||
102 | |||
103 | int notify_called; | ||
93 | }; | 104 | }; |
94 | 105 | ||
95 | /** | 106 | /** |
@@ -325,7 +336,8 @@ peer_connect_notify_cb (void *cls, | |||
325 | GST_cache_peer_connect_notify cb; | 336 | GST_cache_peer_connect_notify cb; |
326 | void *cb_cls; | 337 | void *cb_cls; |
327 | 338 | ||
328 | while (NULL != (ctxt = entry->nctxt_qhead)) | 339 | |
340 | for (ctxt=entry->nctxt_qhead; NULL != ctxt; ctxt=ctxt->next) | ||
329 | { | 341 | { |
330 | if (0 == memcmp (ctxt->target, peer, sizeof (struct GNUNET_PeerIdentity))) | 342 | if (0 == memcmp (ctxt->target, peer, sizeof (struct GNUNET_PeerIdentity))) |
331 | break; | 343 | break; |
@@ -334,6 +346,8 @@ peer_connect_notify_cb (void *cls, | |||
334 | return; | 346 | return; |
335 | cb = ctxt->cb; | 347 | cb = ctxt->cb; |
336 | cb_cls = ctxt->cb_cls; | 348 | cb_cls = ctxt->cb_cls; |
349 | GNUNET_assert (NULL != ctxt->cgh); | ||
350 | ctxt->cgh->nctxt = NULL; | ||
337 | GNUNET_CONTAINER_DLL_remove (entry->nctxt_qhead, entry->nctxt_qtail, ctxt); | 351 | GNUNET_CONTAINER_DLL_remove (entry->nctxt_qhead, entry->nctxt_qtail, ctxt); |
338 | GNUNET_free (ctxt); | 352 | GNUNET_free (ctxt); |
339 | cb (cb_cls, peer); | 353 | cb (cb_cls, peer); |
@@ -426,6 +440,9 @@ cache_get_handle (unsigned int peer_id, | |||
426 | ctxt->target = target; | 440 | ctxt->target = target; |
427 | ctxt->cb = connect_notify_cb; | 441 | ctxt->cb = connect_notify_cb; |
428 | ctxt->cb_cls = connect_notify_cb_cls; | 442 | ctxt->cb_cls = connect_notify_cb_cls; |
443 | GNUNET_assert (NULL == cgh->nctxt); | ||
444 | cgh->nctxt = ctxt; | ||
445 | ctxt->cgh = cgh; | ||
429 | GNUNET_CONTAINER_DLL_insert_tail (entry->nctxt_qhead, entry->nctxt_qtail, ctxt); | 446 | GNUNET_CONTAINER_DLL_insert_tail (entry->nctxt_qhead, entry->nctxt_qtail, ctxt); |
430 | } | 447 | } |
431 | if ((NULL != entry->transport_handle) || (NULL != entry->transport_op)) | 448 | if ((NULL != entry->transport_handle) || (NULL != entry->transport_op)) |
@@ -534,6 +551,13 @@ GST_cache_get_handle_done (struct GSTCacheGetHandle *cgh) | |||
534 | entry->notify_task = GNUNET_SCHEDULER_NO_TASK; | 551 | entry->notify_task = GNUNET_SCHEDULER_NO_TASK; |
535 | } | 552 | } |
536 | GNUNET_CONTAINER_DLL_remove (entry->cgh_qhead, entry->cgh_qtail, cgh); | 553 | GNUNET_CONTAINER_DLL_remove (entry->cgh_qhead, entry->cgh_qtail, cgh); |
554 | if (NULL != cgh->nctxt) | ||
555 | { | ||
556 | GNUNET_assert (cgh == cgh->nctxt->cgh); | ||
557 | GNUNET_CONTAINER_DLL_remove (entry->nctxt_qhead, entry->nctxt_qtail, cgh->nctxt); | ||
558 | GNUNET_free (cgh->nctxt); | ||
559 | } | ||
560 | |||
537 | if (0 == entry->demand) | 561 | if (0 == entry->demand) |
538 | { | 562 | { |
539 | GNUNET_CONTAINER_DLL_insert_tail (lru_cache_head, lru_cache_tail, entry); | 563 | GNUNET_CONTAINER_DLL_insert_tail (lru_cache_head, lru_cache_tail, entry); |
diff --git a/src/testbed/gnunet-service-testbed_oc.c b/src/testbed/gnunet-service-testbed_oc.c index 623b7614b..1148bb8ac 100644 --- a/src/testbed/gnunet-service-testbed_oc.c +++ b/src/testbed/gnunet-service-testbed_oc.c | |||
@@ -25,7 +25,15 @@ | |||
25 | */ | 25 | */ |
26 | 26 | ||
27 | #include "gnunet-service-testbed.h" | 27 | #include "gnunet-service-testbed.h" |
28 | #include "testbed_api_operations.h" | 28 | |
29 | /** | ||
30 | * Redefine LOG with a changed log component string | ||
31 | */ | ||
32 | #ifdef LOG | ||
33 | #undef LOG | ||
34 | #endif | ||
35 | #define LOG(kind,...) \ | ||
36 | GNUNET_log_from (kind, "testbed-OC", __VA_ARGS__) | ||
29 | 37 | ||
30 | 38 | ||
31 | /** | 39 | /** |
@@ -1468,6 +1476,14 @@ rocc_cache_get_handle_transport_cb (void *cls, struct GNUNET_CORE_Handle *ch, | |||
1468 | } | 1476 | } |
1469 | rocc->tcc.th_ = th; | 1477 | rocc->tcc.th_ = th; |
1470 | rocc->tcc.pid = &rocc->a_id; | 1478 | rocc->tcc.pid = &rocc->a_id; |
1479 | if (GNUNET_YES == GNUNET_TRANSPORT_check_neighbour_connected (rocc->tcc.th_, | ||
1480 | rocc->tcc.pid)) | ||
1481 | { | ||
1482 | LOG_DEBUG ("0x%llx: Target peer %4s already connected to local peer: %u\n", | ||
1483 | rocc->op_id, GNUNET_i2s (&rocc->a_id), rocc->peer->id); | ||
1484 | cleanup_rocc (rocc); | ||
1485 | return; | ||
1486 | } | ||
1471 | rocc->attempt_connect_task_id = | 1487 | rocc->attempt_connect_task_id = |
1472 | GNUNET_SCHEDULER_add_now (&attempt_connect_task, rocc); | 1488 | GNUNET_SCHEDULER_add_now (&attempt_connect_task, rocc); |
1473 | } | 1489 | } |