diff options
author | Matthias Wachs <wachs@net.in.tum.de> | 2013-05-28 09:52:15 +0000 |
---|---|---|
committer | Matthias Wachs <wachs@net.in.tum.de> | 2013-05-28 09:52:15 +0000 |
commit | 712084cd824652439e30455f329c9628050ec4fc (patch) | |
tree | a97c01ab68c9e5b1ce586f747aeb228cd6d5380f | |
parent | a15d65e1933ba6def1c2519c32d14edf9d70b4cc (diff) | |
download | gnunet-712084cd824652439e30455f329c9628050ec4fc.tar.gz gnunet-712084cd824652439e30455f329c9628050ec4fc.zip |
changes
3 files changed, 27 insertions, 22 deletions
diff --git a/src/experimentation/gnunet-daemon-experimentation.h b/src/experimentation/gnunet-daemon-experimentation.h index 181256b94..8a8ec67dd 100644 --- a/src/experimentation/gnunet-daemon-experimentation.h +++ b/src/experimentation/gnunet-daemon-experimentation.h | |||
@@ -66,7 +66,7 @@ extern uint32_t GSE_node_capabilities; | |||
66 | 66 | ||
67 | extern uint32_t GSE_my_issuer_count; | 67 | extern uint32_t GSE_my_issuer_count; |
68 | 68 | ||
69 | extern struct Experimentation_Request_Issuer *GSE_my_issuer; | 69 | extern struct Experimentation_Issuer *GSE_my_issuer; |
70 | 70 | ||
71 | /** | 71 | /** |
72 | * Capabilities a node has or an experiment requires | 72 | * Capabilities a node has or an experiment requires |
@@ -167,7 +167,7 @@ struct Node | |||
167 | struct GNUNET_PeerIdentity *issuer_id; | 167 | struct GNUNET_PeerIdentity *issuer_id; |
168 | }; | 168 | }; |
169 | 169 | ||
170 | struct Experimentation_Request_Issuer | 170 | struct Experimentation_Issuer |
171 | { | 171 | { |
172 | struct GNUNET_PeerIdentity issuer_id; | 172 | struct GNUNET_PeerIdentity issuer_id; |
173 | }; | 173 | }; |
diff --git a/src/experimentation/gnunet-daemon-experimentation_experiments.c b/src/experimentation/gnunet-daemon-experimentation_experiments.c index d6ee32c56..fc873361d 100644 --- a/src/experimentation/gnunet-daemon-experimentation_experiments.c +++ b/src/experimentation/gnunet-daemon-experimentation_experiments.c | |||
@@ -56,7 +56,7 @@ static struct GNUNET_CONTAINER_MultiHashMap *experiments; | |||
56 | 56 | ||
57 | uint32_t GSE_my_issuer_count; | 57 | uint32_t GSE_my_issuer_count; |
58 | 58 | ||
59 | struct Experimentation_Request_Issuer *GSE_my_issuer; | 59 | struct Experimentation_Issuer *GSE_my_issuer; |
60 | 60 | ||
61 | 61 | ||
62 | /** | 62 | /** |
@@ -150,10 +150,6 @@ get_it (void *cls, | |||
150 | struct GetCtx *get_ctx = cls; | 150 | struct GetCtx *get_ctx = cls; |
151 | struct Experiment *e = value; | 151 | struct Experiment *e = value; |
152 | 152 | ||
153 | /* Check compability */ | ||
154 | if (get_ctx->n->version.abs_value != e->version.abs_value) | ||
155 | return GNUNET_OK; | ||
156 | |||
157 | get_ctx->get_cb (get_ctx->n, e); | 153 | get_ctx->get_cb (get_ctx->n, e); |
158 | 154 | ||
159 | return GNUNET_OK; | 155 | return GNUNET_OK; |
@@ -418,7 +414,7 @@ GNUNET_EXPERIMENTATION_experiments_start () | |||
418 | } | 414 | } |
419 | 415 | ||
420 | GSE_my_issuer_count = GNUNET_CONTAINER_multihashmap_size (valid_issuers); | 416 | GSE_my_issuer_count = GNUNET_CONTAINER_multihashmap_size (valid_issuers); |
421 | GSE_my_issuer = GNUNET_malloc (GSE_my_issuer_count * sizeof (struct Experimentation_Request_Issuer)); | 417 | GSE_my_issuer = GNUNET_malloc (GSE_my_issuer_count * sizeof (struct Experimentation_Issuer)); |
422 | GNUNET_CONTAINER_multihashmap_iterate (valid_issuers, &create_issuer, GSE_my_issuer); | 418 | GNUNET_CONTAINER_multihashmap_iterate (valid_issuers, &create_issuer, GSE_my_issuer); |
423 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Daemon has %u issuers\n"), GSE_my_issuer_count); | 419 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Daemon has %u issuers\n"), GSE_my_issuer_count); |
424 | 420 | ||
diff --git a/src/experimentation/gnunet-daemon-experimentation_nodes.c b/src/experimentation/gnunet-daemon-experimentation_nodes.c index 9d96bfa2d..dbc89476f 100644 --- a/src/experimentation/gnunet-daemon-experimentation_nodes.c +++ b/src/experimentation/gnunet-daemon-experimentation_nodes.c | |||
@@ -204,7 +204,7 @@ size_t send_request_cb (void *cls, size_t bufsize, void *buf) | |||
204 | struct Node *n = cls; | 204 | struct Node *n = cls; |
205 | struct Experimentation_Request msg; | 205 | struct Experimentation_Request msg; |
206 | size_t msg_size = sizeof (msg); | 206 | size_t msg_size = sizeof (msg); |
207 | size_t ri_size = sizeof (struct Experimentation_Request_Issuer) * GSE_my_issuer_count; | 207 | size_t ri_size = sizeof (struct Experimentation_Issuer) * GSE_my_issuer_count; |
208 | size_t total_size = msg_size + ri_size; | 208 | size_t total_size = msg_size + ri_size; |
209 | 209 | ||
210 | memset (buf, '0', bufsize); | 210 | memset (buf, '0', bufsize); |
@@ -247,7 +247,7 @@ static void send_request (const struct GNUNET_PeerIdentity *peer) | |||
247 | c_issuers = GSE_my_issuer_count; | 247 | c_issuers = GSE_my_issuer_count; |
248 | 248 | ||
249 | size = sizeof (struct Experimentation_Request) + | 249 | size = sizeof (struct Experimentation_Request) + |
250 | c_issuers * sizeof (struct Experimentation_Request_Issuer); | 250 | c_issuers * sizeof (struct Experimentation_Issuer); |
251 | n = GNUNET_malloc (sizeof (struct Node)); | 251 | n = GNUNET_malloc (sizeof (struct Node)); |
252 | n->id = *peer; | 252 | n->id = *peer; |
253 | n->timeout_task = GNUNET_SCHEDULER_add_delayed (EXP_RESPONSE_TIMEOUT, &remove_request, n); | 253 | n->timeout_task = GNUNET_SCHEDULER_add_delayed (EXP_RESPONSE_TIMEOUT, &remove_request, n); |
@@ -274,7 +274,9 @@ size_t send_response_cb (void *cls, size_t bufsize, void *buf) | |||
274 | { | 274 | { |
275 | struct Node *n = cls; | 275 | struct Node *n = cls; |
276 | struct Experimentation_Response msg; | 276 | struct Experimentation_Response msg; |
277 | size_t size = sizeof (msg); | 277 | size_t ri_size = GSE_my_issuer_count * sizeof (struct Experimentation_Issuer); |
278 | size_t msg_size = sizeof (msg); | ||
279 | size_t total_size = msg_size; | ||
278 | 280 | ||
279 | n->cth = NULL; | 281 | n->cth = NULL; |
280 | if (buf == NULL) | 282 | if (buf == NULL) |
@@ -283,16 +285,17 @@ size_t send_response_cb (void *cls, size_t bufsize, void *buf) | |||
283 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Client disconnected\n"); | 285 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Client disconnected\n"); |
284 | return 0; | 286 | return 0; |
285 | } | 287 | } |
286 | GNUNET_assert (bufsize >= size); | 288 | GNUNET_assert (bufsize >= total_size); |
287 | 289 | ||
288 | msg.msg.size = htons (size); | 290 | msg.msg.size = htons (total_size); |
289 | msg.msg.type = htons (GNUNET_MESSAGE_TYPE_EXPERIMENTATION_RESPONSE); | 291 | msg.msg.type = htons (GNUNET_MESSAGE_TYPE_EXPERIMENTATION_RESPONSE); |
290 | msg.capabilities = htonl (GSE_node_capabilities); | 292 | msg.capabilities = htonl (GSE_node_capabilities); |
291 | memcpy (buf, &msg, size); | 293 | memcpy (buf, &msg, msg_size); |
294 | memcpy (&buf[msg_size], GSE_my_issuer, ri_size); | ||
292 | 295 | ||
293 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, _("Sending response to peer %s\n"), | 296 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, _("Sending response to peer %s\n"), |
294 | GNUNET_i2s (&n->id)); | 297 | GNUNET_i2s (&n->id)); |
295 | return size; | 298 | return total_size; |
296 | } | 299 | } |
297 | 300 | ||
298 | 301 | ||
@@ -307,9 +310,10 @@ get_experiments_cb (struct Node *n, struct Experiment *e) | |||
307 | return; | 310 | return; |
308 | } | 311 | } |
309 | 312 | ||
310 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, _("Scheduling experiment `%s' for peer %s\n"), | 313 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, _("Starting experiment `%s' with peer %s\n"), |
314 | e->name, | ||
311 | GNUNET_i2s (&n->id)); | 315 | GNUNET_i2s (&n->id)); |
312 | GNUNET_EXPERIMENTATION_scheduler_add (e); | 316 | //GNUNET_EXPERIMENTATION_scheduler_add (e); |
313 | counter ++; | 317 | counter ++; |
314 | } | 318 | } |
315 | 319 | ||
@@ -329,7 +333,10 @@ static void node_make_active (struct Node *n) | |||
329 | 333 | ||
330 | /* Request experiments for this node to start them */ | 334 | /* Request experiments for this node to start them */ |
331 | for (c1 = 0; c1 < n->issuer_count; c1++) | 335 | for (c1 = 0; c1 < n->issuer_count; c1++) |
336 | { | ||
337 | |||
332 | GNUNET_EXPERIMENTATION_experiments_get (n, &n->issuer_id[c1], &get_experiments_cb); | 338 | GNUNET_EXPERIMENTATION_experiments_get (n, &n->issuer_id[c1], &get_experiments_cb); |
339 | } | ||
333 | } | 340 | } |
334 | 341 | ||
335 | 342 | ||
@@ -344,7 +351,7 @@ static void handle_request (const struct GNUNET_PeerIdentity *peer, | |||
344 | { | 351 | { |
345 | struct Node *n; | 352 | struct Node *n; |
346 | struct Experimentation_Request *rm = (struct Experimentation_Request *) message; | 353 | struct Experimentation_Request *rm = (struct Experimentation_Request *) message; |
347 | struct Experimentation_Request_Issuer *rmi = (struct Experimentation_Request_Issuer *) &rm[1]; | 354 | struct Experimentation_Issuer *rmi = (struct Experimentation_Issuer *) &rm[1]; |
348 | int c1; | 355 | int c1; |
349 | int c2; | 356 | int c2; |
350 | uint32_t ic; | 357 | uint32_t ic; |
@@ -357,7 +364,7 @@ static void handle_request (const struct GNUNET_PeerIdentity *peer, | |||
357 | return; | 364 | return; |
358 | } | 365 | } |
359 | ic = ntohl (rm->issuer_count); | 366 | ic = ntohl (rm->issuer_count); |
360 | if (ntohs (message->size) != sizeof (struct Experimentation_Request) + ic * sizeof (struct Experimentation_Request_Issuer)) | 367 | if (ntohs (message->size) != sizeof (struct Experimentation_Request) + ic * sizeof (struct Experimentation_Issuer)) |
361 | { | 368 | { |
362 | GNUNET_break (0); | 369 | GNUNET_break (0); |
363 | return; | 370 | return; |
@@ -382,7 +389,7 @@ static void handle_request (const struct GNUNET_PeerIdentity *peer, | |||
382 | n->cth = NULL; | 389 | n->cth = NULL; |
383 | } | 390 | } |
384 | update_stats (nodes_requested); | 391 | update_stats (nodes_requested); |
385 | node_make_active (n); | 392 | make_active = GNUNET_YES; |
386 | } | 393 | } |
387 | else if (NULL != (n = GNUNET_CONTAINER_multihashmap_get (nodes_inactive, &peer->hashPubKey))) | 394 | else if (NULL != (n = GNUNET_CONTAINER_multihashmap_get (nodes_inactive, &peer->hashPubKey))) |
388 | { | 395 | { |
@@ -396,7 +403,7 @@ static void handle_request (const struct GNUNET_PeerIdentity *peer, | |||
396 | n = GNUNET_malloc (sizeof (struct Node)); | 403 | n = GNUNET_malloc (sizeof (struct Node)); |
397 | n->id = *peer; | 404 | n->id = *peer; |
398 | n->capabilities = NONE; | 405 | n->capabilities = NONE; |
399 | node_make_active (n); | 406 | make_active = GNUNET_YES; |
400 | } | 407 | } |
401 | 408 | ||
402 | /* Update node */ | 409 | /* Update node */ |
@@ -430,7 +437,9 @@ static void handle_request (const struct GNUNET_PeerIdentity *peer, | |||
430 | /* Send response */ | 437 | /* Send response */ |
431 | n->cth = GNUNET_CORE_notify_transmit_ready (ch, GNUNET_NO, 0, | 438 | n->cth = GNUNET_CORE_notify_transmit_ready (ch, GNUNET_NO, 0, |
432 | GNUNET_TIME_relative_get_forever_(), | 439 | GNUNET_TIME_relative_get_forever_(), |
433 | peer, sizeof (struct Experimentation_Response), | 440 | peer, |
441 | sizeof (struct Experimentation_Response) + | ||
442 | GSE_my_issuer_count * sizeof (struct Experimentation_Issuer), | ||
434 | send_response_cb, n); | 443 | send_response_cb, n); |
435 | } | 444 | } |
436 | 445 | ||