diff options
author | Christian Grothoff <christian@grothoff.org> | 2011-03-11 16:58:27 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2011-03-11 16:58:27 +0000 |
commit | 562b33143ee9fa431a68ea6741e4feb3ba388f83 (patch) | |
tree | 6318eb2c56ff76730708a4791804842c63cf1f81 | |
parent | 64821d4ae43b03b30de3dd136137598c0d5a2ab2 (diff) | |
download | gnunet-562b33143ee9fa431a68ea6741e4feb3ba388f83.tar.gz gnunet-562b33143ee9fa431a68ea6741e4feb3ba388f83.zip |
changing heap remove node api to not pass heap; more fs hacking
-rw-r--r-- | src/dht/gnunet-dht-driver.c | 4 | ||||
-rw-r--r-- | src/dht/gnunet-service-dht.c | 7 | ||||
-rw-r--r-- | src/dv/gnunet-service-dv.c | 4 | ||||
-rw-r--r-- | src/fs/gnunet-service-fs.c | 3 | ||||
-rw-r--r-- | src/fs/gnunet-service-fs.h | 4 | ||||
-rw-r--r-- | src/fs/gnunet-service-fs_pe.c | 207 | ||||
-rw-r--r-- | src/fs/gnunet-service-fs_pr.c | 3 | ||||
-rw-r--r-- | src/fs/gnunet-service-fs_pr.h | 10 | ||||
-rw-r--r-- | src/include/gnunet_container_lib.h | 3 | ||||
-rw-r--r-- | src/include/gnunet_mesh_service.h | 18 | ||||
-rw-r--r-- | src/mesh/mesh.h | 130 | ||||
-rw-r--r-- | src/mesh/mesh_api.c | 2 | ||||
-rw-r--r-- | src/util/Makefile.am | 5 | ||||
-rw-r--r-- | src/util/container_heap.c | 22 | ||||
-rw-r--r-- | src/util/test_container_heap.c | 72 | ||||
-rw-r--r-- | src/vpn/gnunet-daemon-exit.c | 1 | ||||
-rw-r--r-- | src/vpn/gnunet-daemon-vpn.c | 1 |
17 files changed, 302 insertions, 194 deletions
diff --git a/src/dht/gnunet-dht-driver.c b/src/dht/gnunet-dht-driver.c index 7a1606219..d12cc91df 100644 --- a/src/dht/gnunet-dht-driver.c +++ b/src/dht/gnunet-dht-driver.c | |||
@@ -1243,10 +1243,8 @@ do_get(void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc); | |||
1243 | static int | 1243 | static int |
1244 | remove_peer_count(void *cls, const GNUNET_HashCode * key, void *value) | 1244 | remove_peer_count(void *cls, const GNUNET_HashCode * key, void *value) |
1245 | { | 1245 | { |
1246 | struct FindPeerContext *find_peer_ctx = cls; | ||
1247 | struct PeerCount *peer_count = value; | 1246 | struct PeerCount *peer_count = value; |
1248 | GNUNET_CONTAINER_heap_remove_node (find_peer_ctx->peer_min_heap, | 1247 | GNUNET_CONTAINER_heap_remove_node (peer_count->heap_node); |
1249 | peer_count->heap_node); | ||
1250 | GNUNET_free(peer_count); | 1248 | GNUNET_free(peer_count); |
1251 | 1249 | ||
1252 | return GNUNET_YES; | 1250 | return GNUNET_YES; |
diff --git a/src/dht/gnunet-service-dht.c b/src/dht/gnunet-service-dht.c index e455cbc30..08cc7dc88 100644 --- a/src/dht/gnunet-service-dht.c +++ b/src/dht/gnunet-service-dht.c | |||
@@ -2115,8 +2115,7 @@ remove_forward_entry (void *cls, | |||
2115 | struct DHTRouteSource *source_info = cls; | 2115 | struct DHTRouteSource *source_info = cls; |
2116 | struct DHTQueryRecord *record; | 2116 | struct DHTQueryRecord *record; |
2117 | source_info = | 2117 | source_info = |
2118 | GNUNET_CONTAINER_heap_remove_node (forward_list.minHeap, | 2118 | GNUNET_CONTAINER_heap_remove_node (source_info->hnode); |
2119 | source_info->hnode); | ||
2120 | record = source_info->record; | 2119 | record = source_info->record; |
2121 | GNUNET_CONTAINER_DLL_remove (record->head, record->tail, source_info); | 2120 | GNUNET_CONTAINER_DLL_remove (record->head, record->tail, source_info); |
2122 | 2121 | ||
@@ -3733,7 +3732,7 @@ remove_recent (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
3733 | GNUNET_assert (GNUNET_YES == | 3732 | GNUNET_assert (GNUNET_YES == |
3734 | GNUNET_CONTAINER_multihashmap_remove (recent.hashmap, &hash, | 3733 | GNUNET_CONTAINER_multihashmap_remove (recent.hashmap, &hash, |
3735 | req)); | 3734 | req)); |
3736 | GNUNET_CONTAINER_heap_remove_node (recent.minHeap, req->heap_node); | 3735 | GNUNET_CONTAINER_heap_remove_node (req->heap_node); |
3737 | GNUNET_CONTAINER_bloomfilter_free (req->bloom); | 3736 | GNUNET_CONTAINER_bloomfilter_free (req->bloom); |
3738 | GNUNET_free (req); | 3737 | GNUNET_free (req); |
3739 | 3738 | ||
@@ -4241,7 +4240,7 @@ find_client_records (void *cls, const GNUNET_HashCode * key, void *value) | |||
4241 | if (pos != NULL) | 4240 | if (pos != NULL) |
4242 | { | 4241 | { |
4243 | GNUNET_CONTAINER_DLL_remove (record->head, record->tail, pos); | 4242 | GNUNET_CONTAINER_DLL_remove (record->head, record->tail, pos); |
4244 | GNUNET_CONTAINER_heap_remove_node (forward_list.minHeap, pos->hnode); | 4243 | GNUNET_CONTAINER_heap_remove_node (pos->hnode); |
4245 | if (pos->delete_task != GNUNET_SCHEDULER_NO_TASK) | 4244 | if (pos->delete_task != GNUNET_SCHEDULER_NO_TASK) |
4246 | { | 4245 | { |
4247 | GNUNET_SCHEDULER_cancel (pos->delete_task); | 4246 | GNUNET_SCHEDULER_cancel (pos->delete_task); |
diff --git a/src/dv/gnunet-service-dv.c b/src/dv/gnunet-service-dv.c index 900c8f5d7..a6fe9762b 100644 --- a/src/dv/gnunet-service-dv.c +++ b/src/dv/gnunet-service-dv.c | |||
@@ -2010,8 +2010,8 @@ distant_neighbor_free (struct DistantNeighbor *referee) | |||
2010 | GNUNET_CONTAINER_DLL_remove (referrer->referee_head, | 2010 | GNUNET_CONTAINER_DLL_remove (referrer->referee_head, |
2011 | referrer->referee_tail, referee); | 2011 | referrer->referee_tail, referee); |
2012 | } | 2012 | } |
2013 | GNUNET_CONTAINER_heap_remove_node (neighbor_max_heap, referee->max_loc); | 2013 | GNUNET_CONTAINER_heap_remove_node (referee->max_loc); |
2014 | GNUNET_CONTAINER_heap_remove_node (neighbor_min_heap, referee->min_loc); | 2014 | GNUNET_CONTAINER_heap_remove_node (referee->min_loc); |
2015 | GNUNET_CONTAINER_multihashmap_remove_all (extended_neighbors, | 2015 | GNUNET_CONTAINER_multihashmap_remove_all (extended_neighbors, |
2016 | &referee->identity.hashPubKey); | 2016 | &referee->identity.hashPubKey); |
2017 | GNUNET_free_non_null (referee->pkey); | 2017 | GNUNET_free_non_null (referee->pkey); |
diff --git a/src/fs/gnunet-service-fs.c b/src/fs/gnunet-service-fs.c index 101698160..ab16bc834 100644 --- a/src/fs/gnunet-service-fs.c +++ b/src/fs/gnunet-service-fs.c | |||
@@ -1532,8 +1532,7 @@ destroy_pending_request (struct PendingRequest *pr) | |||
1532 | 1532 | ||
1533 | if (pr->hnode != NULL) | 1533 | if (pr->hnode != NULL) |
1534 | { | 1534 | { |
1535 | GNUNET_CONTAINER_heap_remove_node (requests_by_expiration_heap, | 1535 | GNUNET_CONTAINER_heap_remove_node (pr->hnode); |
1536 | pr->hnode); | ||
1537 | pr->hnode = NULL; | 1536 | pr->hnode = NULL; |
1538 | } | 1537 | } |
1539 | if (NULL == pr->client_request_list) | 1538 | if (NULL == pr->client_request_list) |
diff --git a/src/fs/gnunet-service-fs.h b/src/fs/gnunet-service-fs.h index a82206e9c..ee4cea8e2 100644 --- a/src/fs/gnunet-service-fs.h +++ b/src/fs/gnunet-service-fs.h | |||
@@ -70,6 +70,10 @@ struct GSF_PendingRequest; | |||
70 | */ | 70 | */ |
71 | struct GSF_LocalClient; | 71 | struct GSF_LocalClient; |
72 | 72 | ||
73 | /** | ||
74 | * Information kept per plan per request ('pe' module). | ||
75 | */ | ||
76 | struct GSF_RequestPlan; | ||
73 | 77 | ||
74 | /** | 78 | /** |
75 | * Our connection to the datastore. | 79 | * Our connection to the datastore. |
diff --git a/src/fs/gnunet-service-fs_pe.c b/src/fs/gnunet-service-fs_pe.c index e7608653e..306bb948c 100644 --- a/src/fs/gnunet-service-fs_pe.c +++ b/src/fs/gnunet-service-fs_pe.c | |||
@@ -28,13 +28,51 @@ | |||
28 | #include "gnunet-service-fs_pe.h" | 28 | #include "gnunet-service-fs_pe.h" |
29 | #include "gnunet-service-fs_pr.h" | 29 | #include "gnunet-service-fs_pr.h" |
30 | 30 | ||
31 | |||
32 | /** | ||
33 | * Information we keep per request per peer. This is a doubly-linked | ||
34 | * list (with head and tail in the 'struct GSF_PendingRequestData') | ||
35 | * with one entry in each heap of each 'struct PeerPlan'. Each | ||
36 | * entry tracks information relevant for this request and this peer. | ||
37 | */ | ||
38 | struct GSF_RequestPlan | ||
39 | { | ||
40 | |||
41 | /** | ||
42 | * This is a doubly-linked list. | ||
43 | */ | ||
44 | struct GSF_RequestPlan *next; | ||
45 | |||
46 | /** | ||
47 | * This is a doubly-linked list. | ||
48 | */ | ||
49 | struct GSF_RequestPlan *prev; | ||
50 | |||
51 | /** | ||
52 | * Heap node associated with this request and this peer. | ||
53 | */ | ||
54 | struct GNUNET_CONTAINER_HeapNode *hn; | ||
55 | |||
56 | /** | ||
57 | * Associated pending request. | ||
58 | */ | ||
59 | struct GSF_PendingRequest *pr; | ||
60 | |||
61 | /** | ||
62 | * Earliest time we'd be happy to transmit this request. | ||
63 | */ | ||
64 | struct GNUNET_TIME_Absolute earliest_transmission; | ||
65 | |||
66 | }; | ||
67 | |||
68 | |||
31 | /** | 69 | /** |
32 | * Transmission plan for a peer. | 70 | * Transmission plan for a peer. |
33 | */ | 71 | */ |
34 | struct PeerPlan | 72 | struct PeerPlan |
35 | { | 73 | { |
36 | /** | 74 | /** |
37 | * Heap with pending queries, smaller weights mean higher priority. | 75 | * Heap with pending queries (struct GSF_RequestPlan), smaller weights mean higher priority. |
38 | */ | 76 | */ |
39 | struct GNUNET_CONTAINER_Heap *heap; | 77 | struct GNUNET_CONTAINER_Heap *heap; |
40 | 78 | ||
@@ -62,6 +100,28 @@ static struct GNUNET_CONTAINER_MultiHashMap *plans; | |||
62 | 100 | ||
63 | 101 | ||
64 | /** | 102 | /** |
103 | * Insert the given request plan into the heap with the appropriate weight. | ||
104 | * | ||
105 | * @param pp associated peer's plan | ||
106 | * @param rp request to plan | ||
107 | */ | ||
108 | static void | ||
109 | plan (struct PeerPlan *pp, | ||
110 | struct GSF_RequestPlan *rp) | ||
111 | { | ||
112 | GNUNET_CONTAINER_HeapCostType weight; | ||
113 | struct GSF_PendingRequestData *prd; | ||
114 | |||
115 | prd = GSF_pending_request_get_data_ (rp->pr); | ||
116 | weight = 0; // FIXME: calculate real weight! | ||
117 | // FIXME: calculate 'rp->earliest_transmission'! | ||
118 | rp->hn = GNUNET_CONTAINER_heap_insert (pp->heap, | ||
119 | rp, | ||
120 | weight); | ||
121 | } | ||
122 | |||
123 | |||
124 | /** | ||
65 | * Figure out when and how to transmit to the given peer. | 125 | * Figure out when and how to transmit to the given peer. |
66 | * | 126 | * |
67 | * @param cls the 'struct GSF_ConnectedPeer' for transmission | 127 | * @param cls the 'struct GSF_ConnectedPeer' for transmission |
@@ -86,7 +146,7 @@ transmit_message_callback (void *cls, | |||
86 | void *buf) | 146 | void *buf) |
87 | { | 147 | { |
88 | struct PeerPlan *pp = cls; | 148 | struct PeerPlan *pp = cls; |
89 | struct GSF_PendingRequest *pr; | 149 | struct GSF_RequestPlan *rp; |
90 | size_t msize; | 150 | size_t msize; |
91 | 151 | ||
92 | if (NULL == buf) | 152 | if (NULL == buf) |
@@ -95,8 +155,8 @@ transmit_message_callback (void *cls, | |||
95 | pp->task = GNUNET_SCHEDULER_add_now (&schedule_peer_transmission, pp); | 155 | pp->task = GNUNET_SCHEDULER_add_now (&schedule_peer_transmission, pp); |
96 | return 0; | 156 | return 0; |
97 | } | 157 | } |
98 | pr = GNUNET_CONTAINER_heap_peek (pp->heap); | 158 | rp = GNUNET_CONTAINER_heap_peek (pp->heap); |
99 | msize = GSF_pending_request_get_message_ (pr, buf_size, buf); | 159 | msize = GSF_pending_request_get_message_ (rp->pr, buf_size, buf); |
100 | if (msize > buf_size) | 160 | if (msize > buf_size) |
101 | { | 161 | { |
102 | /* buffer to small (message changed), try again */ | 162 | /* buffer to small (message changed), try again */ |
@@ -104,8 +164,9 @@ transmit_message_callback (void *cls, | |||
104 | return 0; | 164 | return 0; |
105 | } | 165 | } |
106 | /* remove from root, add again elsewhere... */ | 166 | /* remove from root, add again elsewhere... */ |
107 | GNUNET_assert (pr == GNUNET_CONTAINER_heap_remove_root (pp->heap)); | 167 | GNUNET_assert (rp == GNUNET_CONTAINER_heap_remove_root (pp->heap)); |
108 | GSF_plan_add_ (pp->cp, pr); | 168 | rp->hn = NULL; |
169 | plan (pp, rp); | ||
109 | return msize; | 170 | return msize; |
110 | } | 171 | } |
111 | 172 | ||
@@ -121,7 +182,8 @@ schedule_peer_transmission (void *cls, | |||
121 | const struct GNUNET_SCHEDULER_TaskContext *tc) | 182 | const struct GNUNET_SCHEDULER_TaskContext *tc) |
122 | { | 183 | { |
123 | struct PeerPlan *pp = cls; | 184 | struct PeerPlan *pp = cls; |
124 | struct GSF_PendingRequest *pr; | 185 | struct GSF_RequestPlan *rp; |
186 | struct GSF_PendingRequestData *prd; | ||
125 | size_t msize; | 187 | size_t msize; |
126 | struct GNUNET_TIME_Relative delay; | 188 | struct GNUNET_TIME_Relative delay; |
127 | 189 | ||
@@ -131,17 +193,17 @@ schedule_peer_transmission (void *cls, | |||
131 | if (0 == GNUNET_CONTAINER_heap_get_size (pp->heap)) | 193 | if (0 == GNUNET_CONTAINER_heap_get_size (pp->heap)) |
132 | return; | 194 | return; |
133 | GNUNET_assert (NULL == pp->pth); | 195 | GNUNET_assert (NULL == pp->pth); |
134 | pr = GNUNET_CONTAINER_heap_peek (pp->heap); | 196 | rp = GNUNET_CONTAINER_heap_peek (pp->heap); |
135 | if (0) // FIXME: if (re)transmission should wait, wait... | 197 | prd = GSF_pending_request_get_data_ (rp->pr); |
198 | delay = GNUNET_TIME_absolute_get_remaining (rp->earliest_transmission); | ||
199 | if (delay.rel_value > 0) | ||
136 | { | 200 | { |
137 | delay = GNUNET_TIME_UNIT_SECONDS; | ||
138 | // FIXME | ||
139 | pp->task = GNUNET_SCHEDULER_add_delayed (delay, | 201 | pp->task = GNUNET_SCHEDULER_add_delayed (delay, |
140 | &schedule_peer_transmission, | 202 | &schedule_peer_transmission, |
141 | pp); | 203 | pp); |
142 | return; | 204 | return; |
143 | } | 205 | } |
144 | msize = GSF_pending_request_get_message_ (pr, 0, NULL); | 206 | msize = GSF_pending_request_get_message_ (rp->pr, 0, NULL); |
145 | pp->pth = GSF_peer_transmit_ (pp->cp, | 207 | pp->pth = GSF_peer_transmit_ (pp->cp, |
146 | GNUNET_YES, | 208 | GNUNET_YES, |
147 | 0 /* FIXME: pr->priority? */, | 209 | 0 /* FIXME: pr->priority? */, |
@@ -165,7 +227,8 @@ GSF_plan_add_ (const struct GSF_ConnectedPeer *cp, | |||
165 | { | 227 | { |
166 | struct GNUNET_PeerIdentity id; | 228 | struct GNUNET_PeerIdentity id; |
167 | struct PeerPlan *pp; | 229 | struct PeerPlan *pp; |
168 | GNUNET_CONTAINER_HeapCostType weight; | 230 | struct GSF_PendingRequestData *prd; |
231 | struct GSF_RequestPlan *rp; | ||
169 | 232 | ||
170 | GSF_connected_peer_get_identity_ (cp, &id); | 233 | GSF_connected_peer_get_identity_ (cp, &id); |
171 | pp = GNUNET_CONTAINER_multihashmap_get (plans, | 234 | pp = GNUNET_CONTAINER_multihashmap_get (plans, |
@@ -179,13 +242,16 @@ GSF_plan_add_ (const struct GSF_ConnectedPeer *cp, | |||
179 | pp, | 242 | pp, |
180 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY); | 243 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY); |
181 | } | 244 | } |
182 | weight = 0; // FIXME: calculate real weight! | 245 | prd = GSF_pending_request_get_data_ (pr); |
183 | GNUNET_CONTAINER_heap_insert (pp->heap, | 246 | rp = GNUNET_malloc (sizeof (struct GSF_RequestPlan)); |
184 | pr, | 247 | rp->pr = pr; |
185 | weight); | 248 | GNUNET_CONTAINER_DLL_insert (prd->rp_head, |
249 | prd->rp_tail, | ||
250 | rp); | ||
251 | plan (pp, rp); | ||
186 | if (pp->pth != NULL) | 252 | if (pp->pth != NULL) |
187 | { | 253 | { |
188 | if (pr != GNUNET_CONTAINER_heap_peek (pp->heap)) | 254 | if (rp != GNUNET_CONTAINER_heap_peek (pp->heap)) |
189 | return; | 255 | return; |
190 | GSF_peer_transmit_cancel_ (pp->pth); | 256 | GSF_peer_transmit_cancel_ (pp->pth); |
191 | pp->pth = NULL; | 257 | pp->pth = NULL; |
@@ -208,6 +274,8 @@ GSF_plan_notify_peer_disconnect_ (const struct GSF_ConnectedPeer *cp) | |||
208 | { | 274 | { |
209 | struct GNUNET_PeerIdentity id; | 275 | struct GNUNET_PeerIdentity id; |
210 | struct PeerPlan *pp; | 276 | struct PeerPlan *pp; |
277 | struct GSF_RequestPlan *rp; | ||
278 | struct GSF_PendingRequestData *prd; | ||
211 | 279 | ||
212 | GSF_connected_peer_get_identity_ (cp, &id); | 280 | GSF_connected_peer_get_identity_ (cp, &id); |
213 | pp = GNUNET_CONTAINER_multihashmap_get (plans, | 281 | pp = GNUNET_CONTAINER_multihashmap_get (plans, |
@@ -219,101 +287,40 @@ GSF_plan_notify_peer_disconnect_ (const struct GSF_ConnectedPeer *cp) | |||
219 | GSF_peer_transmit_cancel_ (pp->pth); | 287 | GSF_peer_transmit_cancel_ (pp->pth); |
220 | if (GNUNET_SCHEDULER_NO_TASK != pp->task) | 288 | if (GNUNET_SCHEDULER_NO_TASK != pp->task) |
221 | GNUNET_SCHEDULER_cancel (pp->task); | 289 | GNUNET_SCHEDULER_cancel (pp->task); |
222 | GNUNET_CONTAINER_heap_destroy (pp->heap); | 290 | while (NULL != (rp = GNUNET_CONTAINER_heap_remove_root (pp->heap))) |
223 | GNUNET_free (pp); | ||
224 | } | ||
225 | |||
226 | |||
227 | /** | ||
228 | * Closure for 'find_request'. | ||
229 | */ | ||
230 | struct FindRequestClosure | ||
231 | { | ||
232 | /** | ||
233 | * Place to store the node that was found (NULL for none). | ||
234 | */ | ||
235 | struct GNUNET_CONTAINER_HeapNode *node; | ||
236 | |||
237 | /** | ||
238 | * Value we're looking for | ||
239 | */ | ||
240 | const struct GSF_PendingRequest *pr; | ||
241 | }; | ||
242 | |||
243 | |||
244 | /** | ||
245 | * Find a heap node where the value matches the | ||
246 | * pending request given in the closure. | ||
247 | * | ||
248 | * @param cls the 'struct FindRequestClosure' | ||
249 | * @param node heap structure we're looking for on a match | ||
250 | * @param element the pending request stored in the heap | ||
251 | * @param cost weight of the request | ||
252 | * @return GNUNET_YES to continue looking | ||
253 | */ | ||
254 | static int | ||
255 | find_request (void *cls, | ||
256 | struct GNUNET_CONTAINER_HeapNode *node, | ||
257 | void *element, | ||
258 | GNUNET_CONTAINER_HeapCostType cost) | ||
259 | { | ||
260 | struct FindRequestClosure *frc = cls; | ||
261 | struct GSF_PendingRequest *pr = element; | ||
262 | |||
263 | if (pr == frc->pr) | ||
264 | { | ||
265 | frc->node = node; | ||
266 | return GNUNET_NO; | ||
267 | } | ||
268 | return GNUNET_YES; | ||
269 | } | ||
270 | |||
271 | |||
272 | /** | ||
273 | * Remove the given request from all heaps. * FIXME: O(n) -- inefficient! | ||
274 | * | ||
275 | * @param cls 'struct GSF_PendingRequest' to purge | ||
276 | * @param key identity of the peer we're currently looking at (unused) | ||
277 | * @param value PeerPlan for the given peer to search for the 'cls' | ||
278 | * @return GNUNET_OK (continue iteration) | ||
279 | */ | ||
280 | static int | ||
281 | remove_request (void *cls, | ||
282 | const GNUNET_HashCode *key, | ||
283 | void *value) | ||
284 | { | ||
285 | const struct GSF_PendingRequest *pr = cls; | ||
286 | struct PeerPlan *pp = value; | ||
287 | struct GNUNET_CONTAINER_Heap *h = pp->heap; | ||
288 | struct FindRequestClosure frc; | ||
289 | |||
290 | frc.pr = pr; | ||
291 | do | ||
292 | { | 291 | { |
293 | frc.node = NULL; | 292 | prd = GSF_pending_request_get_data_ (rp->pr); |
294 | GNUNET_CONTAINER_heap_iterate (h, &find_request, &frc); | 293 | GNUNET_CONTAINER_DLL_remove (prd->rp_head, |
295 | if (frc.node != NULL) | 294 | prd->rp_tail, |
296 | GNUNET_CONTAINER_heap_remove_node (h, frc.node); | 295 | rp); |
296 | GNUNET_free (rp); | ||
297 | } | 297 | } |
298 | while (NULL != frc.node); | 298 | GNUNET_CONTAINER_heap_destroy (pp->heap); |
299 | return GNUNET_OK; | 299 | GNUNET_free (pp); |
300 | } | 300 | } |
301 | 301 | ||
302 | 302 | ||
303 | /** | 303 | /** |
304 | * Notify the plan about a request being done; destroy all entries | 304 | * Notify the plan about a request being done; destroy all entries |
305 | * associated with this request. Note that this implementation is | 305 | * associated with this request. |
306 | * currently terribly inefficient (O(n)) and could instead be done in | ||
307 | * O(1). But for now, I first want to see it work correctly... | ||
308 | * | 306 | * |
309 | * @param pr request that is done | 307 | * @param pr request that is done |
310 | */ | 308 | */ |
311 | void | 309 | void |
312 | GSF_plan_notify_request_done_ (const struct GSF_PendingRequest *pr) | 310 | GSF_plan_notify_request_done_ (const struct GSF_PendingRequest *pr) |
313 | { | 311 | { |
314 | GNUNET_CONTAINER_multihashmap_iterate (plans, | 312 | struct GSF_RequestPlan *rp; |
315 | &remove_request, | 313 | struct GSF_PendingRequestData *prd; |
316 | (void*) pr); | 314 | |
315 | while (NULL != (rp = prd->rp_head)) | ||
316 | { | ||
317 | prd = GSF_pending_request_get_data_ (rp->pr); | ||
318 | GNUNET_CONTAINER_heap_remove_node (rp->hn); | ||
319 | GNUNET_CONTAINER_DLL_remove (prd->rp_head, | ||
320 | prd->rp_tail, | ||
321 | rp); | ||
322 | GNUNET_free (rp); | ||
323 | } | ||
317 | } | 324 | } |
318 | 325 | ||
319 | 326 | ||
diff --git a/src/fs/gnunet-service-fs_pr.c b/src/fs/gnunet-service-fs_pr.c index ff2f7a3a3..2c983eaed 100644 --- a/src/fs/gnunet-service-fs_pr.c +++ b/src/fs/gnunet-service-fs_pr.c | |||
@@ -526,8 +526,7 @@ clean_request (void *cls, | |||
526 | GNUNET_CONTAINER_bloomfilter_free (pr->bf); | 526 | GNUNET_CONTAINER_bloomfilter_free (pr->bf); |
527 | GNUNET_PEER_change_rc (pr->sender_pid, -1); | 527 | GNUNET_PEER_change_rc (pr->sender_pid, -1); |
528 | if (NULL != pr->hnode) | 528 | if (NULL != pr->hnode) |
529 | GNUNET_CONTAINER_heap_remove_node (requests_by_expiration_heap, | 529 | GNUNET_CONTAINER_heap_remove_node (pr->hnode); |
530 | pr->hnode); | ||
531 | if (NULL != pr->qe) | 530 | if (NULL != pr->qe) |
532 | GNUNET_DATASTORE_cancel (pr->qe); | 531 | GNUNET_DATASTORE_cancel (pr->qe); |
533 | if (NULL != pr->gh) | 532 | if (NULL != pr->gh) |
diff --git a/src/fs/gnunet-service-fs_pr.h b/src/fs/gnunet-service-fs_pr.h index 9632df015..5759bee4a 100644 --- a/src/fs/gnunet-service-fs_pr.h +++ b/src/fs/gnunet-service-fs_pr.h | |||
@@ -92,6 +92,16 @@ struct GSF_PendingRequestData | |||
92 | struct GNUNET_PeerIdentity target; | 92 | struct GNUNET_PeerIdentity target; |
93 | 93 | ||
94 | /** | 94 | /** |
95 | * Fields for the plan module to track a DLL with the request. | ||
96 | */ | ||
97 | struct GSF_RequestPlan *rp_head; | ||
98 | |||
99 | /** | ||
100 | * Fields for the plan module to track a DLL with the request. | ||
101 | */ | ||
102 | struct GSF_RequestPlan *rp_tail; | ||
103 | |||
104 | /** | ||
95 | * Current TTL for the request. | 105 | * Current TTL for the request. |
96 | */ | 106 | */ |
97 | struct GNUNET_TIME_Absolute ttl; | 107 | struct GNUNET_TIME_Absolute ttl; |
diff --git a/src/include/gnunet_container_lib.h b/src/include/gnunet_container_lib.h index 41ed4bd3f..6b7016c74 100644 --- a/src/include/gnunet_container_lib.h +++ b/src/include/gnunet_container_lib.h | |||
@@ -1011,8 +1011,7 @@ GNUNET_CONTAINER_heap_remove_root (struct GNUNET_CONTAINER_Heap *heap); | |||
1011 | * @return element data stored at the node, NULL if heap is empty | 1011 | * @return element data stored at the node, NULL if heap is empty |
1012 | */ | 1012 | */ |
1013 | void * | 1013 | void * |
1014 | GNUNET_CONTAINER_heap_remove_node (struct GNUNET_CONTAINER_Heap *heap, | 1014 | GNUNET_CONTAINER_heap_remove_node (struct GNUNET_CONTAINER_HeapNode *node); |
1015 | struct GNUNET_CONTAINER_HeapNode *node); | ||
1016 | 1015 | ||
1017 | 1016 | ||
1018 | /** | 1017 | /** |
diff --git a/src/include/gnunet_mesh_service.h b/src/include/gnunet_mesh_service.h index 1677c714c..738811950 100644 --- a/src/include/gnunet_mesh_service.h +++ b/src/include/gnunet_mesh_service.h | |||
@@ -61,6 +61,7 @@ struct GNUNET_MESH_Tunnel; | |||
61 | * @param cls closure (set from GNUNET_MESH_connect) | 61 | * @param cls closure (set from GNUNET_MESH_connect) |
62 | * @param tunnel connection to the other end | 62 | * @param tunnel connection to the other end |
63 | * @param tunnel_ctx place to store local state associated with the tunnel | 63 | * @param tunnel_ctx place to store local state associated with the tunnel |
64 | * @param sender who sent the message | ||
64 | * @param message the actual message | 65 | * @param message the actual message |
65 | * @param atsi performance data for the connection | 66 | * @param atsi performance data for the connection |
66 | * @return GNUNET_OK to keep the connection open, | 67 | * @return GNUNET_OK to keep the connection open, |
@@ -69,7 +70,8 @@ struct GNUNET_MESH_Tunnel; | |||
69 | typedef int | 70 | typedef int |
70 | (*GNUNET_MESH_MessageCallback) (void *cls, | 71 | (*GNUNET_MESH_MessageCallback) (void *cls, |
71 | struct GNUNET_MESH_Tunnel *tunnel, | 72 | struct GNUNET_MESH_Tunnel *tunnel, |
72 | void **tunnel_ctx, | 73 | void **tunnel_ctx, |
74 | const struct GNUNET_PeerIdentity *sender, | ||
73 | const struct GNUNET_MessageHeader *message, | 75 | const struct GNUNET_MessageHeader *message, |
74 | const struct GNUNET_TRANSPORT_ATS_Information *atsi); | 76 | const struct GNUNET_TRANSPORT_ATS_Information *atsi); |
75 | 77 | ||
@@ -249,6 +251,18 @@ GNUNET_MESH_peer_request_connect_add (struct GNUNET_MESH_Tunnel *tunnel, | |||
249 | 251 | ||
250 | 252 | ||
251 | /** | 253 | /** |
254 | * Request that a peer should be removed from the tunnel. The existing | ||
255 | * disconnect handler will be called ONCE if we were connected. | ||
256 | * | ||
257 | * @param tunnel handle to existing tunnel | ||
258 | * @param peer peer to remove | ||
259 | */ | ||
260 | void | ||
261 | GNUNET_MESH_peer_request_connect_del (struct GNUNET_MESH_Tunnel *tunnel, | ||
262 | const struct GNUNET_PeerIdentity *peer); | ||
263 | |||
264 | |||
265 | /** | ||
252 | * Request that the mesh should try to connect to a peer supporting the given | 266 | * Request that the mesh should try to connect to a peer supporting the given |
253 | * message type. | 267 | * message type. |
254 | * | 268 | * |
@@ -300,6 +314,7 @@ struct GNUNET_MESH_TransmitHandle; | |||
300 | * @param cork is corking allowed for this transmission? | 314 | * @param cork is corking allowed for this transmission? |
301 | * @param priority how important is the message? | 315 | * @param priority how important is the message? |
302 | * @param maxdelay how long can the message wait? | 316 | * @param maxdelay how long can the message wait? |
317 | * @param target destination for the message, NULL for multicast to all tunnel targets | ||
303 | * @param notify_size how many bytes of buffer space does notify want? | 318 | * @param notify_size how many bytes of buffer space does notify want? |
304 | * @param notify function to call when buffer space is available; | 319 | * @param notify function to call when buffer space is available; |
305 | * will be called with NULL on timeout or if the overall queue | 320 | * will be called with NULL on timeout or if the overall queue |
@@ -319,6 +334,7 @@ GNUNET_MESH_notify_transmit_ready (struct | |||
319 | struct | 334 | struct |
320 | GNUNET_TIME_Relative | 335 | GNUNET_TIME_Relative |
321 | maxdelay, | 336 | maxdelay, |
337 | // const struct GNUNET_PeerIdentity *target, | ||
322 | size_t | 338 | size_t |
323 | notify_size, | 339 | notify_size, |
324 | GNUNET_CONNECTION_TransmitReadyNotify | 340 | GNUNET_CONNECTION_TransmitReadyNotify |
diff --git a/src/mesh/mesh.h b/src/mesh/mesh.h index 085f3ef4d..e51b0c890 100644 --- a/src/mesh/mesh.h +++ b/src/mesh/mesh.h | |||
@@ -21,6 +21,15 @@ | |||
21 | /** | 21 | /** |
22 | * @author Bartlomiej Polot | 22 | * @author Bartlomiej Polot |
23 | * @file mesh/mesh.h | 23 | * @file mesh/mesh.h |
24 | * | ||
25 | * TODO: | ||
26 | * - soft stateing (keep-alive (CHANGE?) / timeout / disconnect) -- not a message issue | ||
27 | * - error reporting (CREATE/CHANGE/ADD/DEL?) -- new message! | ||
28 | * - partial disconnect reporting -- same as error reporting? | ||
29 | * - add vs create? change vs. keep-alive? same msg or different ones? -- thinking... | ||
30 | * - speed requirement specification (change?) in mesh API -- API call | ||
31 | * | ||
32 | * - API messages! | ||
24 | */ | 33 | */ |
25 | 34 | ||
26 | 35 | ||
@@ -35,67 +44,130 @@ | |||
35 | struct GNUNET_MESH_ManipulatePath | 44 | struct GNUNET_MESH_ManipulatePath |
36 | { | 45 | { |
37 | /** | 46 | /** |
38 | * Type: GNUNET_MESSAGE_TYPE_MESH_PATH_[CREATE|CHANGE|ADD] | 47 | * Type: GNUNET_MESSAGE_TYPE_MESH_PATH_[CREATE|CHANGE|ADD|DEL] |
48 | * | ||
49 | * Size: sizeof(struct GNUNET_MESH_ManipulatePath) + path_length * sizeof (struct GNUNET_PeerIdentity) | ||
39 | */ | 50 | */ |
40 | struct GNUNET_MessageHeader header; | 51 | struct GNUNET_MessageHeader header; |
41 | 52 | ||
42 | /** | 53 | /** |
43 | * Id of the tunnel this path belongs to | 54 | * Id of the tunnel this path belongs to, unique in conjunction with the origin. |
44 | */ | 55 | */ |
45 | uint32_t tid; | 56 | uint32_t tid GNUNET_PACKED; |
46 | 57 | ||
47 | /** | 58 | /** |
48 | * Information about speed requirements | 59 | * Information about speed requirements. If the tunnel cannot sustain the |
60 | * minimum bandwidth, packets are to be dropped. | ||
49 | */ | 61 | */ |
50 | uint32_t speed_min; | 62 | uint32_t speed_min GNUNET_PACKED; |
51 | uint32_t speed_max; | ||
52 | 63 | ||
53 | /** | 64 | /** |
54 | * Number of hops in the path given below | 65 | * path_length structs defining the *whole* path from the origin [0] to the |
66 | * final destination [path_length-1]. | ||
55 | */ | 67 | */ |
56 | uint16_t path_length; | 68 | // struct GNUNET_PeerIdentity peers[path_length]; |
69 | }; | ||
57 | 70 | ||
71 | /** | ||
72 | * Message for mesh data traffic to all tunnel targets. | ||
73 | */ | ||
74 | struct GNUNET_MESH_OriginMulticast | ||
75 | { | ||
58 | /** | 76 | /** |
59 | * path_length structs defining the *whole* path | 77 | * Type: GNUNET_MESSAGE_TYPE_DATA_MULTICAST |
78 | */ | ||
79 | struct GNUNET_MessageHeader header; | ||
80 | |||
81 | /** | ||
82 | * TID of the tunnel | ||
83 | */ | ||
84 | uint32_t tid GNUNET_PACKED; | ||
85 | |||
86 | /** | ||
87 | * OID of the tunnel | ||
88 | */ | ||
89 | struct GNUNET_PeerIdentity oid; | ||
90 | |||
91 | /** | ||
92 | * FIXME: Some form of authentication | ||
93 | */ | ||
94 | // uint32_t token; | ||
95 | |||
96 | /** | ||
97 | * Payload follows | ||
60 | */ | 98 | */ |
61 | struct GNUNET_PeerIdentity peers[]; | ||
62 | }; | 99 | }; |
63 | 100 | ||
101 | |||
64 | /** | 102 | /** |
65 | * Message for mesh data traffic | 103 | * Message for mesh data traffic to a particular destination from origin. |
66 | */ | 104 | */ |
67 | struct GNUNET_MESH_Data | 105 | struct GNUNET_MESH_DataMessageFromOrigin |
68 | { | 106 | { |
69 | /** | 107 | /** |
70 | * Type: GNUNET_MESSAGE_TYPE_DATA_[GO|BACK] | 108 | * Type: GNUNET_MESSAGE_TYPE_DATA_MESSAGE_FROM_ORIGIN |
71 | */ | 109 | */ |
72 | struct GNUNET_MessageHeader header; | 110 | struct GNUNET_MessageHeader header; |
73 | 111 | ||
74 | /** | 112 | /** |
113 | * TID of the tunnel | ||
114 | */ | ||
115 | uint32_t tid GNUNET_PACKED; | ||
116 | |||
117 | /** | ||
75 | * OID of the tunnel | 118 | * OID of the tunnel |
76 | */ | 119 | */ |
77 | struct GNUNET_PeerIdentity oid; | 120 | struct GNUNET_PeerIdentity oid; |
78 | 121 | ||
79 | /** | 122 | /** |
123 | * Destination. | ||
124 | */ | ||
125 | struct GNUNET_PeerIdentity destination; | ||
126 | |||
127 | /** | ||
128 | * FIXME: Some form of authentication | ||
129 | */ | ||
130 | // uint32_t token; | ||
131 | |||
132 | /** | ||
133 | * Payload follows | ||
134 | */ | ||
135 | }; | ||
136 | |||
137 | |||
138 | /** | ||
139 | * Message for mesh data traffic from a tunnel participant to origin. | ||
140 | */ | ||
141 | struct GNUNET_MESH_DataMessageToOrigin | ||
142 | { | ||
143 | /** | ||
144 | * Type: GNUNET_MESSAGE_TYPE_DATA_MESSAGE_TO_ORIGIN | ||
145 | */ | ||
146 | struct GNUNET_MessageHeader header; | ||
147 | |||
148 | /** | ||
80 | * TID of the tunnel | 149 | * TID of the tunnel |
81 | */ | 150 | */ |
82 | uint32_t tid; | 151 | uint32_t tid GNUNET_PACKED; |
83 | 152 | ||
84 | /** | 153 | /** |
85 | * FIXME Some form of authentication | 154 | * OID of the tunnel |
86 | */ | 155 | */ |
87 | uint32_t token; | 156 | struct GNUNET_PeerIdentity oid; |
88 | 157 | ||
89 | /** | 158 | /** |
90 | * Size of payload | 159 | * Sender of the message. |
91 | * FIXME uint16 enough? | ||
92 | */ | 160 | */ |
93 | uint16_t size; | 161 | struct GNUNET_PeerIdentity sender; |
94 | 162 | ||
95 | /** | 163 | /** |
96 | * Payload | 164 | * FIXME: Some form of authentication |
165 | */ | ||
166 | // uint32_t token; | ||
167 | |||
168 | /** | ||
169 | * Payload follows | ||
97 | */ | 170 | */ |
98 | uint8_t data[]; | ||
99 | }; | 171 | }; |
100 | 172 | ||
101 | /** | 173 | /** |
@@ -109,24 +181,20 @@ struct GNUNET_MESH_SpeedNotify | |||
109 | struct GNUNET_MessageHeader header; | 181 | struct GNUNET_MessageHeader header; |
110 | 182 | ||
111 | /** | 183 | /** |
112 | * OID of the tunnel | 184 | * TID of the tunnel |
113 | */ | 185 | */ |
114 | struct GNUNET_PeerIdentity oid; | 186 | uint32_t tid GNUNET_PACKED; |
115 | 187 | ||
116 | /** | 188 | /** |
117 | * TID of the tunnel | 189 | * OID of the tunnel |
118 | */ | 190 | */ |
119 | uint32_t tid; | 191 | struct GNUNET_PeerIdentity oid; |
120 | 192 | ||
121 | /** | 193 | /** |
122 | * Slowest link down the path | 194 | * Slowest link down the path (above minimum speed requirement). |
123 | */ | 195 | */ |
124 | uint32_t speed_min; | 196 | uint32_t speed_min; |
125 | 197 | ||
126 | /** | ||
127 | * Fastest link down the path | ||
128 | */ | ||
129 | uint32_t speed_max; | ||
130 | }; | 198 | }; |
131 | 199 | ||
132 | #endif \ No newline at end of file | 200 | #endif |
diff --git a/src/mesh/mesh_api.c b/src/mesh/mesh_api.c index f539312cf..053449fbe 100644 --- a/src/mesh/mesh_api.c +++ b/src/mesh/mesh_api.c | |||
@@ -315,7 +315,7 @@ core_receive (void *cls, | |||
315 | } | 315 | } |
316 | 316 | ||
317 | return handler->callback (handle->cls, &tunnel->tunnel, | 317 | return handler->callback (handle->cls, &tunnel->tunnel, |
318 | &tunnel->tunnel.ctx, rmessage, atsi); | 318 | &tunnel->tunnel.ctx, other, rmessage, atsi); |
319 | } | 319 | } |
320 | 320 | ||
321 | 321 | ||
diff --git a/src/util/Makefile.am b/src/util/Makefile.am index 9b43b5f05..b24b3ab7c 100644 --- a/src/util/Makefile.am +++ b/src/util/Makefile.am | |||
@@ -92,7 +92,7 @@ gnunet_service_resolver_LDADD = \ | |||
92 | $(GN_LIBINTL) | 92 | $(GN_LIBINTL) |
93 | gnunet_service_resolver_DEPENDENCIES = \ | 93 | gnunet_service_resolver_DEPENDENCIES = \ |
94 | libgnunetutil.la | 94 | libgnunetutil.la |
95 | 95 | ||
96 | 96 | ||
97 | gnunet_resolver_SOURCES = \ | 97 | gnunet_resolver_SOURCES = \ |
98 | gnunet-resolver.c | 98 | gnunet-resolver.c |
@@ -229,7 +229,8 @@ test_crypto_aes_LDADD = \ | |||
229 | test_crypto_aes_weak_SOURCES = \ | 229 | test_crypto_aes_weak_SOURCES = \ |
230 | test_crypto_aes_weak.c | 230 | test_crypto_aes_weak.c |
231 | test_crypto_aes_weak_LDADD = \ | 231 | test_crypto_aes_weak_LDADD = \ |
232 | $(top_builddir)/src/util/libgnunetutil.la | 232 | $(top_builddir)/src/util/libgnunetutil.la \ |
233 | -lgcrypt | ||
233 | 234 | ||
234 | test_crypto_crc_SOURCES = \ | 235 | test_crypto_crc_SOURCES = \ |
235 | test_crypto_crc.c | 236 | test_crypto_crc.c |
diff --git a/src/util/container_heap.c b/src/util/container_heap.c index 7cd30a0a7..c332cdd63 100644 --- a/src/util/container_heap.c +++ b/src/util/container_heap.c | |||
@@ -37,6 +37,11 @@ | |||
37 | struct GNUNET_CONTAINER_HeapNode | 37 | struct GNUNET_CONTAINER_HeapNode |
38 | { | 38 | { |
39 | /** | 39 | /** |
40 | * Heap this node belongs to. | ||
41 | */ | ||
42 | struct GNUNET_CONTAINER_Heap *heap; | ||
43 | |||
44 | /** | ||
40 | * Parent node. | 45 | * Parent node. |
41 | */ | 46 | */ |
42 | struct GNUNET_CONTAINER_HeapNode *parent; | 47 | struct GNUNET_CONTAINER_HeapNode *parent; |
@@ -340,6 +345,7 @@ GNUNET_CONTAINER_heap_insert (struct GNUNET_CONTAINER_Heap *heap, | |||
340 | struct GNUNET_CONTAINER_HeapNode *node; | 345 | struct GNUNET_CONTAINER_HeapNode *node; |
341 | 346 | ||
342 | node = GNUNET_malloc (sizeof (struct GNUNET_CONTAINER_HeapNode)); | 347 | node = GNUNET_malloc (sizeof (struct GNUNET_CONTAINER_HeapNode)); |
348 | node->heap = heap; | ||
343 | node->element = element; | 349 | node->element = element; |
344 | node->cost = cost; | 350 | node->cost = cost; |
345 | heap->size++; | 351 | heap->size++; |
@@ -405,10 +411,10 @@ GNUNET_CONTAINER_heap_remove_root (struct GNUNET_CONTAINER_Heap *heap) | |||
405 | * 'size' field of the tree. | 411 | * 'size' field of the tree. |
406 | */ | 412 | */ |
407 | static void | 413 | static void |
408 | remove_node (struct GNUNET_CONTAINER_Heap *heap, | 414 | remove_node (struct GNUNET_CONTAINER_HeapNode *node) |
409 | struct GNUNET_CONTAINER_HeapNode *node) | ||
410 | { | 415 | { |
411 | struct GNUNET_CONTAINER_HeapNode *ancestor; | 416 | struct GNUNET_CONTAINER_HeapNode *ancestor; |
417 | struct GNUNET_CONTAINER_Heap *heap = node->heap; | ||
412 | 418 | ||
413 | /* update 'size' of the ancestors */ | 419 | /* update 'size' of the ancestors */ |
414 | ancestor = node; | 420 | ancestor = node; |
@@ -471,20 +477,20 @@ remove_node (struct GNUNET_CONTAINER_Heap *heap, | |||
471 | /** | 477 | /** |
472 | * Removes a node from the heap. | 478 | * Removes a node from the heap. |
473 | * | 479 | * |
474 | * @param heap heap to modify | ||
475 | * @param node node to remove | 480 | * @param node node to remove |
476 | * @return element data stored at the node | 481 | * @return element data stored at the node |
477 | */ | 482 | */ |
478 | void * | 483 | void * |
479 | GNUNET_CONTAINER_heap_remove_node (struct GNUNET_CONTAINER_Heap *heap, | 484 | GNUNET_CONTAINER_heap_remove_node (struct GNUNET_CONTAINER_HeapNode *node) |
480 | struct GNUNET_CONTAINER_HeapNode *node) | ||
481 | { | 485 | { |
482 | void *ret; | 486 | void *ret; |
483 | 487 | struct GNUNET_CONTAINER_Heap *heap; | |
488 | |||
489 | heap = node->heap; | ||
484 | CHECK (heap->root); | 490 | CHECK (heap->root); |
485 | if (heap->walk_pos == node) | 491 | if (heap->walk_pos == node) |
486 | (void) GNUNET_CONTAINER_heap_walk_get_next (heap); | 492 | (void) GNUNET_CONTAINER_heap_walk_get_next (heap); |
487 | remove_node (heap, node); | 493 | remove_node (node); |
488 | heap->size--; | 494 | heap->size--; |
489 | ret = node->element; | 495 | ret = node->element; |
490 | if (heap->walk_pos == node) | 496 | if (heap->walk_pos == node) |
@@ -518,7 +524,7 @@ GNUNET_CONTAINER_heap_update_cost (struct GNUNET_CONTAINER_Heap *heap, | |||
518 | (heap->size == heap->root->tree_size + 1) ); | 524 | (heap->size == heap->root->tree_size + 1) ); |
519 | CHECK (heap->root); | 525 | CHECK (heap->root); |
520 | #endif | 526 | #endif |
521 | remove_node (heap, node); | 527 | remove_node (node); |
522 | #if DEBUG | 528 | #if DEBUG |
523 | CHECK (heap->root); | 529 | CHECK (heap->root); |
524 | GNUNET_assert ( ( (heap->size == 1) && | 530 | GNUNET_assert ( ( (heap->size == 1) && |
diff --git a/src/util/test_container_heap.c b/src/util/test_container_heap.c index 87bc49129..6a0d5d68d 100644 --- a/src/util/test_container_heap.c +++ b/src/util/test_container_heap.c | |||
@@ -93,7 +93,7 @@ check () | |||
93 | n2 = GNUNET_CONTAINER_heap_insert (myHeap, "78", 78); | 93 | n2 = GNUNET_CONTAINER_heap_insert (myHeap, "78", 78); |
94 | GNUNET_assert (2 == GNUNET_CONTAINER_heap_get_size (myHeap)); | 94 | GNUNET_assert (2 == GNUNET_CONTAINER_heap_get_size (myHeap)); |
95 | GNUNET_assert (0 == strcmp ("78", | 95 | GNUNET_assert (0 == strcmp ("78", |
96 | GNUNET_CONTAINER_heap_remove_node (myHeap, n2))); | 96 | GNUNET_CONTAINER_heap_remove_node (n2))); |
97 | GNUNET_assert (1 == GNUNET_CONTAINER_heap_get_size (myHeap)); | 97 | GNUNET_assert (1 == GNUNET_CONTAINER_heap_get_size (myHeap)); |
98 | GNUNET_CONTAINER_heap_iterate (myHeap, &iterator_callback, NULL); | 98 | GNUNET_CONTAINER_heap_iterate (myHeap, &iterator_callback, NULL); |
99 | 99 | ||
@@ -110,13 +110,13 @@ check () | |||
110 | n5 = GNUNET_CONTAINER_heap_insert (myHeap, "100", 100); | 110 | n5 = GNUNET_CONTAINER_heap_insert (myHeap, "100", 100); |
111 | n6 = GNUNET_CONTAINER_heap_insert (myHeap, "30/200", 30); | 111 | n6 = GNUNET_CONTAINER_heap_insert (myHeap, "30/200", 30); |
112 | GNUNET_assert (5 == GNUNET_CONTAINER_heap_get_size (myHeap)); | 112 | GNUNET_assert (5 == GNUNET_CONTAINER_heap_get_size (myHeap)); |
113 | GNUNET_CONTAINER_heap_remove_node (myHeap, n5); | 113 | GNUNET_CONTAINER_heap_remove_node (n5); |
114 | r = GNUNET_CONTAINER_heap_remove_root (myHeap); /* n1 */ | 114 | r = GNUNET_CONTAINER_heap_remove_root (myHeap); /* n1 */ |
115 | GNUNET_assert (NULL != r); | 115 | GNUNET_assert (NULL != r); |
116 | GNUNET_assert (0 == strcmp ("11", | 116 | GNUNET_assert (0 == strcmp ("11", |
117 | r)); | 117 | r)); |
118 | GNUNET_CONTAINER_heap_update_cost (myHeap, n6, 200); | 118 | GNUNET_CONTAINER_heap_update_cost (myHeap, n6, 200); |
119 | GNUNET_CONTAINER_heap_remove_node (myHeap, n3); | 119 | GNUNET_CONTAINER_heap_remove_node (n3); |
120 | r = GNUNET_CONTAINER_heap_remove_root (myHeap); /* n4 */ | 120 | r = GNUNET_CONTAINER_heap_remove_root (myHeap); /* n4 */ |
121 | GNUNET_assert (NULL != r); | 121 | GNUNET_assert (NULL != r); |
122 | GNUNET_assert (0 == strcmp ("50", | 122 | GNUNET_assert (0 == strcmp ("50", |
@@ -137,7 +137,7 @@ check () | |||
137 | n1 = GNUNET_CONTAINER_heap_insert (myHeap, "10", 10); | 137 | n1 = GNUNET_CONTAINER_heap_insert (myHeap, "10", 10); |
138 | GNUNET_CONTAINER_heap_update_cost (myHeap, n1, 15); | 138 | GNUNET_CONTAINER_heap_update_cost (myHeap, n1, 15); |
139 | 139 | ||
140 | r = GNUNET_CONTAINER_heap_remove_node (myHeap,n1); | 140 | r = GNUNET_CONTAINER_heap_remove_node (n1); |
141 | GNUNET_assert (NULL != r); | 141 | GNUNET_assert (NULL != r); |
142 | GNUNET_assert (0 == strcmp ("10", r)); | 142 | GNUNET_assert (0 == strcmp ("10", r)); |
143 | 143 | ||
@@ -145,10 +145,10 @@ check () | |||
145 | n2 = GNUNET_CONTAINER_heap_insert (myHeap, "20", 10); | 145 | n2 = GNUNET_CONTAINER_heap_insert (myHeap, "20", 10); |
146 | 146 | ||
147 | GNUNET_CONTAINER_heap_walk_get_next (myHeap); | 147 | GNUNET_CONTAINER_heap_walk_get_next (myHeap); |
148 | r = GNUNET_CONTAINER_heap_remove_node (myHeap,n2); | 148 | r = GNUNET_CONTAINER_heap_remove_node (n2); |
149 | GNUNET_assert (NULL != r); | 149 | GNUNET_assert (NULL != r); |
150 | GNUNET_assert (0 == strcmp ("20", r)); | 150 | GNUNET_assert (0 == strcmp ("20", r)); |
151 | r = GNUNET_CONTAINER_heap_remove_node (myHeap,n1); | 151 | r = GNUNET_CONTAINER_heap_remove_node (n1); |
152 | GNUNET_assert (NULL != r); | 152 | GNUNET_assert (NULL != r); |
153 | GNUNET_assert (0 == strcmp ("10", r)); | 153 | GNUNET_assert (0 == strcmp ("10", r)); |
154 | 154 | ||
@@ -156,8 +156,8 @@ check () | |||
156 | n2 = GNUNET_CONTAINER_heap_insert (myHeap, "20", 10); | 156 | n2 = GNUNET_CONTAINER_heap_insert (myHeap, "20", 10); |
157 | n3 = GNUNET_CONTAINER_heap_insert (myHeap, "30", 10); | 157 | n3 = GNUNET_CONTAINER_heap_insert (myHeap, "30", 10); |
158 | 158 | ||
159 | GNUNET_CONTAINER_heap_remove_node (myHeap,n2); | 159 | GNUNET_CONTAINER_heap_remove_node (n2); |
160 | GNUNET_CONTAINER_heap_remove_node (myHeap,n1); | 160 | GNUNET_CONTAINER_heap_remove_node (n1); |
161 | r = GNUNET_CONTAINER_heap_remove_root (myHeap); | 161 | r = GNUNET_CONTAINER_heap_remove_root (myHeap); |
162 | GNUNET_assert (NULL != r); | 162 | GNUNET_assert (NULL != r); |
163 | GNUNET_assert (0 == strcmp ("30", r)); | 163 | GNUNET_assert (0 == strcmp ("30", r)); |
@@ -166,9 +166,9 @@ check () | |||
166 | n2 = GNUNET_CONTAINER_heap_insert (myHeap, "20", 10); | 166 | n2 = GNUNET_CONTAINER_heap_insert (myHeap, "20", 10); |
167 | n3 = GNUNET_CONTAINER_heap_insert (myHeap, "30", 10); | 167 | n3 = GNUNET_CONTAINER_heap_insert (myHeap, "30", 10); |
168 | 168 | ||
169 | GNUNET_CONTAINER_heap_remove_node (myHeap,n2); | 169 | GNUNET_CONTAINER_heap_remove_node (n2); |
170 | GNUNET_CONTAINER_heap_remove_node (myHeap,n1); | 170 | GNUNET_CONTAINER_heap_remove_node (n1); |
171 | r = GNUNET_CONTAINER_heap_remove_node (myHeap, n3); | 171 | r = GNUNET_CONTAINER_heap_remove_node ( n3); |
172 | GNUNET_assert (NULL != r); | 172 | GNUNET_assert (NULL != r); |
173 | GNUNET_assert (0 == strcmp ("30", r)); | 173 | GNUNET_assert (0 == strcmp ("30", r)); |
174 | 174 | ||
@@ -176,7 +176,7 @@ check () | |||
176 | n2 = GNUNET_CONTAINER_heap_insert (myHeap, "20", 20); | 176 | n2 = GNUNET_CONTAINER_heap_insert (myHeap, "20", 20); |
177 | n3 = GNUNET_CONTAINER_heap_insert (myHeap, "30", 30); | 177 | n3 = GNUNET_CONTAINER_heap_insert (myHeap, "30", 30); |
178 | 178 | ||
179 | GNUNET_assert (0 == nstrcmp ("20", GNUNET_CONTAINER_heap_remove_node (myHeap,n2))); | 179 | GNUNET_assert (0 == nstrcmp ("20", GNUNET_CONTAINER_heap_remove_node (n2))); |
180 | GNUNET_assert (0 == nstrcmp ("10", GNUNET_CONTAINER_heap_remove_root (myHeap))); | 180 | GNUNET_assert (0 == nstrcmp ("10", GNUNET_CONTAINER_heap_remove_root (myHeap))); |
181 | GNUNET_assert (0 == nstrcmp ("30", GNUNET_CONTAINER_heap_remove_root (myHeap))); | 181 | GNUNET_assert (0 == nstrcmp ("30", GNUNET_CONTAINER_heap_remove_root (myHeap))); |
182 | 182 | ||
@@ -191,11 +191,11 @@ check () | |||
191 | n7 = GNUNET_CONTAINER_heap_insert (myHeap, "70", 10); | 191 | n7 = GNUNET_CONTAINER_heap_insert (myHeap, "70", 10); |
192 | n8 = GNUNET_CONTAINER_heap_insert (myHeap, "80", 10); | 192 | n8 = GNUNET_CONTAINER_heap_insert (myHeap, "80", 10); |
193 | 193 | ||
194 | GNUNET_assert (0 == nstrcmp ("30", GNUNET_CONTAINER_heap_remove_node (myHeap,n3))); | 194 | GNUNET_assert (0 == nstrcmp ("30", GNUNET_CONTAINER_heap_remove_node (n3))); |
195 | 195 | ||
196 | // Cleaning up... | 196 | // Cleaning up... |
197 | GNUNET_assert (0 == nstrcmp ("60", GNUNET_CONTAINER_heap_remove_node (myHeap,n6))); | 197 | GNUNET_assert (0 == nstrcmp ("60", GNUNET_CONTAINER_heap_remove_node (n6))); |
198 | GNUNET_assert (0 == nstrcmp ("50", GNUNET_CONTAINER_heap_remove_node (myHeap,n5))); | 198 | GNUNET_assert (0 == nstrcmp ("50", GNUNET_CONTAINER_heap_remove_node (n5))); |
199 | 199 | ||
200 | // Testing heap_walk_get_next | 200 | // Testing heap_walk_get_next |
201 | GNUNET_CONTAINER_heap_walk_get_next (myHeap); | 201 | GNUNET_CONTAINER_heap_walk_get_next (myHeap); |
@@ -204,11 +204,11 @@ check () | |||
204 | GNUNET_CONTAINER_heap_walk_get_next (myHeap); | 204 | GNUNET_CONTAINER_heap_walk_get_next (myHeap); |
205 | GNUNET_CONTAINER_heap_walk_get_next (myHeap); | 205 | GNUNET_CONTAINER_heap_walk_get_next (myHeap); |
206 | 206 | ||
207 | GNUNET_assert (0 == nstrcmp ("10", GNUNET_CONTAINER_heap_remove_node (myHeap,n1))); | 207 | GNUNET_assert (0 == nstrcmp ("10", GNUNET_CONTAINER_heap_remove_node (n1))); |
208 | GNUNET_assert (0 == nstrcmp ("20", GNUNET_CONTAINER_heap_remove_node (myHeap,n2))); | 208 | GNUNET_assert (0 == nstrcmp ("20", GNUNET_CONTAINER_heap_remove_node (n2))); |
209 | GNUNET_assert (0 == nstrcmp ("40", GNUNET_CONTAINER_heap_remove_node (myHeap,n4))); | 209 | GNUNET_assert (0 == nstrcmp ("40", GNUNET_CONTAINER_heap_remove_node (n4))); |
210 | GNUNET_assert (0 == nstrcmp ("70", GNUNET_CONTAINER_heap_remove_node (myHeap,n7))); | 210 | GNUNET_assert (0 == nstrcmp ("70", GNUNET_CONTAINER_heap_remove_node (n7))); |
211 | GNUNET_assert (0 == nstrcmp ("80", GNUNET_CONTAINER_heap_remove_node (myHeap,n8))); | 211 | GNUNET_assert (0 == nstrcmp ("80", GNUNET_CONTAINER_heap_remove_node (n8))); |
212 | 212 | ||
213 | // End Testing remove_node | 213 | // End Testing remove_node |
214 | 214 | ||
@@ -220,30 +220,30 @@ check () | |||
220 | n1 = GNUNET_CONTAINER_heap_insert (myHeap, "10", 10); | 220 | n1 = GNUNET_CONTAINER_heap_insert (myHeap, "10", 10); |
221 | GNUNET_CONTAINER_heap_update_cost (myHeap, n1, 15); | 221 | GNUNET_CONTAINER_heap_update_cost (myHeap, n1, 15); |
222 | 222 | ||
223 | GNUNET_assert (0 == nstrcmp ("10", GNUNET_CONTAINER_heap_remove_node (myHeap,n1))); | 223 | GNUNET_assert (0 == nstrcmp ("10", GNUNET_CONTAINER_heap_remove_node (n1))); |
224 | 224 | ||
225 | n1 = GNUNET_CONTAINER_heap_insert (myHeap, "10", 10); | 225 | n1 = GNUNET_CONTAINER_heap_insert (myHeap, "10", 10); |
226 | n2 = GNUNET_CONTAINER_heap_insert (myHeap, "20", 10); | 226 | n2 = GNUNET_CONTAINER_heap_insert (myHeap, "20", 10); |
227 | 227 | ||
228 | GNUNET_CONTAINER_heap_walk_get_next (myHeap); | 228 | GNUNET_CONTAINER_heap_walk_get_next (myHeap); |
229 | GNUNET_assert (0 == nstrcmp ("20", GNUNET_CONTAINER_heap_remove_node (myHeap,n2))); | 229 | GNUNET_assert (0 == nstrcmp ("20", GNUNET_CONTAINER_heap_remove_node (n2))); |
230 | GNUNET_assert (0 == nstrcmp ("10", GNUNET_CONTAINER_heap_remove_node (myHeap,n1))); | 230 | GNUNET_assert (0 == nstrcmp ("10", GNUNET_CONTAINER_heap_remove_node (n1))); |
231 | 231 | ||
232 | n1 = GNUNET_CONTAINER_heap_insert (myHeap, "10", 10); | 232 | n1 = GNUNET_CONTAINER_heap_insert (myHeap, "10", 10); |
233 | n2 = GNUNET_CONTAINER_heap_insert (myHeap, "20", 10); | 233 | n2 = GNUNET_CONTAINER_heap_insert (myHeap, "20", 10); |
234 | n3 = GNUNET_CONTAINER_heap_insert (myHeap, "30", 10); | 234 | n3 = GNUNET_CONTAINER_heap_insert (myHeap, "30", 10); |
235 | 235 | ||
236 | GNUNET_CONTAINER_heap_remove_node (myHeap,n2); | 236 | GNUNET_CONTAINER_heap_remove_node (n2); |
237 | GNUNET_CONTAINER_heap_remove_node (myHeap,n1); | 237 | GNUNET_CONTAINER_heap_remove_node (n1); |
238 | GNUNET_assert (0 == nstrcmp ("30", GNUNET_CONTAINER_heap_remove_root (myHeap))); | 238 | GNUNET_assert (0 == nstrcmp ("30", GNUNET_CONTAINER_heap_remove_root (myHeap))); |
239 | 239 | ||
240 | n1 = GNUNET_CONTAINER_heap_insert (myHeap, "10", 10); | 240 | n1 = GNUNET_CONTAINER_heap_insert (myHeap, "10", 10); |
241 | n2 = GNUNET_CONTAINER_heap_insert (myHeap, "20", 10); | 241 | n2 = GNUNET_CONTAINER_heap_insert (myHeap, "20", 10); |
242 | n3 = GNUNET_CONTAINER_heap_insert (myHeap, "30", 10); | 242 | n3 = GNUNET_CONTAINER_heap_insert (myHeap, "30", 10); |
243 | 243 | ||
244 | GNUNET_CONTAINER_heap_remove_node (myHeap,n2); | 244 | GNUNET_CONTAINER_heap_remove_node (n2); |
245 | GNUNET_CONTAINER_heap_remove_node (myHeap,n1); | 245 | GNUNET_CONTAINER_heap_remove_node (n1); |
246 | GNUNET_assert (0 == nstrcmp ("30", GNUNET_CONTAINER_heap_remove_node (myHeap,n3))); | 246 | GNUNET_assert (0 == nstrcmp ("30", GNUNET_CONTAINER_heap_remove_node (n3))); |
247 | 247 | ||
248 | n1 = GNUNET_CONTAINER_heap_insert (myHeap, "10", 10); | 248 | n1 = GNUNET_CONTAINER_heap_insert (myHeap, "10", 10); |
249 | n2 = GNUNET_CONTAINER_heap_insert (myHeap, "20", 20); | 249 | n2 = GNUNET_CONTAINER_heap_insert (myHeap, "20", 20); |
@@ -256,11 +256,11 @@ check () | |||
256 | n7 = GNUNET_CONTAINER_heap_insert (myHeap, "70", 10); | 256 | n7 = GNUNET_CONTAINER_heap_insert (myHeap, "70", 10); |
257 | n8 = GNUNET_CONTAINER_heap_insert (myHeap, "80", 10); | 257 | n8 = GNUNET_CONTAINER_heap_insert (myHeap, "80", 10); |
258 | 258 | ||
259 | GNUNET_assert (0 == nstrcmp ("30", GNUNET_CONTAINER_heap_remove_node (myHeap,n3))); | 259 | GNUNET_assert (0 == nstrcmp ("30", GNUNET_CONTAINER_heap_remove_node (n3))); |
260 | 260 | ||
261 | // Cleaning up... | 261 | // Cleaning up... |
262 | GNUNET_assert (0 == nstrcmp ("60", GNUNET_CONTAINER_heap_remove_node (myHeap,n6))); | 262 | GNUNET_assert (0 == nstrcmp ("60", GNUNET_CONTAINER_heap_remove_node (n6))); |
263 | GNUNET_assert (0 == nstrcmp ("50", GNUNET_CONTAINER_heap_remove_node (myHeap,n5))); | 263 | GNUNET_assert (0 == nstrcmp ("50", GNUNET_CONTAINER_heap_remove_node (n5))); |
264 | 264 | ||
265 | // Testing heap_walk_get_next | 265 | // Testing heap_walk_get_next |
266 | GNUNET_CONTAINER_heap_walk_get_next (myHeap); | 266 | GNUNET_CONTAINER_heap_walk_get_next (myHeap); |
@@ -269,11 +269,11 @@ check () | |||
269 | GNUNET_CONTAINER_heap_walk_get_next (myHeap); | 269 | GNUNET_CONTAINER_heap_walk_get_next (myHeap); |
270 | GNUNET_CONTAINER_heap_walk_get_next (myHeap); | 270 | GNUNET_CONTAINER_heap_walk_get_next (myHeap); |
271 | 271 | ||
272 | GNUNET_assert (0 == nstrcmp ("10", GNUNET_CONTAINER_heap_remove_node (myHeap,n1))); | 272 | GNUNET_assert (0 == nstrcmp ("10", GNUNET_CONTAINER_heap_remove_node (n1))); |
273 | GNUNET_assert (0 == nstrcmp ("20", GNUNET_CONTAINER_heap_remove_node (myHeap,n2))); | 273 | GNUNET_assert (0 == nstrcmp ("20", GNUNET_CONTAINER_heap_remove_node (n2))); |
274 | GNUNET_assert (0 == nstrcmp ("40", GNUNET_CONTAINER_heap_remove_node (myHeap,n4))); | 274 | GNUNET_assert (0 == nstrcmp ("40", GNUNET_CONTAINER_heap_remove_node (n4))); |
275 | GNUNET_assert (0 == nstrcmp ("70", GNUNET_CONTAINER_heap_remove_node (myHeap,n7))); | 275 | GNUNET_assert (0 == nstrcmp ("70", GNUNET_CONTAINER_heap_remove_node (n7))); |
276 | GNUNET_assert (0 == nstrcmp ("80", GNUNET_CONTAINER_heap_remove_node (myHeap,n8))); | 276 | GNUNET_assert (0 == nstrcmp ("80", GNUNET_CONTAINER_heap_remove_node (n8))); |
277 | 277 | ||
278 | // End Testing remove_node | 278 | // End Testing remove_node |
279 | 279 | ||
diff --git a/src/vpn/gnunet-daemon-exit.c b/src/vpn/gnunet-daemon-exit.c index f6198894f..03e9831c8 100644 --- a/src/vpn/gnunet-daemon-exit.c +++ b/src/vpn/gnunet-daemon-exit.c | |||
@@ -447,6 +447,7 @@ static int | |||
447 | receive_udp_service (void *cls, | 447 | receive_udp_service (void *cls, |
448 | struct GNUNET_MESH_Tunnel *tunnel, | 448 | struct GNUNET_MESH_Tunnel *tunnel, |
449 | void **tunnel_ctx, | 449 | void **tunnel_ctx, |
450 | const struct GNUNET_PeerIdentity *sender, | ||
450 | const struct GNUNET_MessageHeader *message, | 451 | const struct GNUNET_MessageHeader *message, |
451 | const struct GNUNET_TRANSPORT_ATS_Information *atsi) | 452 | const struct GNUNET_TRANSPORT_ATS_Information *atsi) |
452 | { | 453 | { |
diff --git a/src/vpn/gnunet-daemon-vpn.c b/src/vpn/gnunet-daemon-vpn.c index 50c9d14b1..4d6a569f4 100644 --- a/src/vpn/gnunet-daemon-vpn.c +++ b/src/vpn/gnunet-daemon-vpn.c | |||
@@ -418,6 +418,7 @@ add_additional_port (struct map_entry *me, uint16_t port) | |||
418 | static int | 418 | static int |
419 | receive_udp_back (void *cls, struct GNUNET_MESH_Tunnel* tunnel, | 419 | receive_udp_back (void *cls, struct GNUNET_MESH_Tunnel* tunnel, |
420 | void **tunnel_ctx, | 420 | void **tunnel_ctx, |
421 | const struct GNUNET_PeerIdentity *sender, | ||
421 | const struct GNUNET_MessageHeader *message, | 422 | const struct GNUNET_MessageHeader *message, |
422 | const struct GNUNET_TRANSPORT_ATS_Information *atsi) | 423 | const struct GNUNET_TRANSPORT_ATS_Information *atsi) |
423 | { | 424 | { |