diff options
author | Christian Grothoff <christian@grothoff.org> | 2015-10-08 17:09:42 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2015-10-08 17:09:42 +0000 |
commit | b910380795760d26a7cc38510c1f313bb1a72ea7 (patch) | |
tree | adcb256486cf4b97284ccb21850197037a802ba7 /src/core/test_core_api_reliability.c | |
parent | 0f420b095bd839165613d0bd681f5a8b1614e24e (diff) | |
download | gnunet-b910380795760d26a7cc38510c1f313bb1a72ea7.tar.gz gnunet-b910380795760d26a7cc38510c1f313bb1a72ea7.zip |
redefining core message timeout semantics and core-core-API messaging to address (hypothetical?) stalls which may explain #3863. This kind-of breaks the API in that the timeout now has a different semantic -- it's an advisory as to when the app would like the message transmitted, the transmission will no longer actually time out. However, that was the documented semantics before, just not the actual behavior. Most applications didn't rely on it, and tests still pass, so I didn't break too much...
Diffstat (limited to 'src/core/test_core_api_reliability.c')
-rw-r--r-- | src/core/test_core_api_reliability.c | 58 |
1 files changed, 35 insertions, 23 deletions
diff --git a/src/core/test_core_api_reliability.c b/src/core/test_core_api_reliability.c index f2fadb59e..bd55565e3 100644 --- a/src/core/test_core_api_reliability.c +++ b/src/core/test_core_api_reliability.c | |||
@@ -41,7 +41,7 @@ | |||
41 | /** | 41 | /** |
42 | * How long until we give up on transmitting the message? | 42 | * How long until we give up on transmitting the message? |
43 | */ | 43 | */ |
44 | #define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 6000) | 44 | #define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 600) |
45 | 45 | ||
46 | /** | 46 | /** |
47 | * What delay do we request from the core service for transmission? | 47 | * What delay do we request from the core service for transmission? |
@@ -55,9 +55,9 @@ static unsigned long long total_bytes; | |||
55 | 55 | ||
56 | static struct GNUNET_TIME_Absolute start_time; | 56 | static struct GNUNET_TIME_Absolute start_time; |
57 | 57 | ||
58 | static struct GNUNET_SCHEDULER_Task * err_task; | 58 | static struct GNUNET_SCHEDULER_Task *err_task; |
59 | 59 | ||
60 | static struct GNUNET_SCHEDULER_Task * connect_task; | 60 | static struct GNUNET_SCHEDULER_Task *connect_task; |
61 | 61 | ||
62 | 62 | ||
63 | struct PeerContext | 63 | struct PeerContext |
@@ -185,9 +185,9 @@ transmit_ready (void *cls, size_t size, void *buf) | |||
185 | unsigned int ret; | 185 | unsigned int ret; |
186 | 186 | ||
187 | GNUNET_assert (size <= GNUNET_CONSTANTS_MAX_ENCRYPTED_MESSAGE_SIZE); | 187 | GNUNET_assert (size <= GNUNET_CONSTANTS_MAX_ENCRYPTED_MESSAGE_SIZE); |
188 | if (buf == NULL) | 188 | if (NULL == buf) |
189 | { | 189 | { |
190 | if (p1.ch != NULL) | 190 | if (NULL != p1.ch) |
191 | GNUNET_break (NULL != | 191 | GNUNET_break (NULL != |
192 | GNUNET_CORE_notify_transmit_ready (p1.ch, GNUNET_NO, | 192 | GNUNET_CORE_notify_transmit_ready (p1.ch, GNUNET_NO, |
193 | GNUNET_CORE_PRIO_BEST_EFFORT, | 193 | GNUNET_CORE_PRIO_BEST_EFFORT, |
@@ -221,7 +221,8 @@ transmit_ready (void *cls, size_t size, void *buf) | |||
221 | while (size - ret >= s); | 221 | while (size - ret >= s); |
222 | GNUNET_SCHEDULER_cancel (err_task); | 222 | GNUNET_SCHEDULER_cancel (err_task); |
223 | err_task = | 223 | err_task = |
224 | GNUNET_SCHEDULER_add_delayed (TIMEOUT, &terminate_task_error, NULL); | 224 | GNUNET_SCHEDULER_add_delayed (TIMEOUT, |
225 | &terminate_task_error, NULL); | ||
225 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 226 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
226 | "Returning total message block of size %u\n", ret); | 227 | "Returning total message block of size %u\n", ret); |
227 | total_bytes += ret; | 228 | total_bytes += ret; |
@@ -241,10 +242,10 @@ connect_notify (void *cls, const struct GNUNET_PeerIdentity *peer) | |||
241 | if (pc == &p1) | 242 | if (pc == &p1) |
242 | { | 243 | { |
243 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 244 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
244 | "Encrypted connection established to peer `%4s'\n", | 245 | "Encrypted connection established to peer `%s'\n", |
245 | GNUNET_i2s (peer)); | 246 | GNUNET_i2s (peer)); |
246 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 247 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
247 | "Asking core (1) for transmission to peer `%4s'\n", | 248 | "Asking core (1) for transmission to peer `%s'\n", |
248 | GNUNET_i2s (&p2.id)); | 249 | GNUNET_i2s (&p2.id)); |
249 | GNUNET_SCHEDULER_cancel (err_task); | 250 | GNUNET_SCHEDULER_cancel (err_task); |
250 | err_task = | 251 | err_task = |
@@ -268,7 +269,7 @@ disconnect_notify (void *cls, const struct GNUNET_PeerIdentity *peer) | |||
268 | if (0 == memcmp (&pc->id, peer, sizeof (struct GNUNET_PeerIdentity))) | 269 | if (0 == memcmp (&pc->id, peer, sizeof (struct GNUNET_PeerIdentity))) |
269 | return; | 270 | return; |
270 | pc->connect_status = 0; | 271 | pc->connect_status = 0; |
271 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Encrypted connection to `%4s' cut\n", | 272 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Encrypted connection to `%s' cut\n", |
272 | GNUNET_i2s (peer)); | 273 | GNUNET_i2s (peer)); |
273 | } | 274 | } |
274 | 275 | ||
@@ -278,7 +279,7 @@ inbound_notify (void *cls, const struct GNUNET_PeerIdentity *other, | |||
278 | const struct GNUNET_MessageHeader *message) | 279 | const struct GNUNET_MessageHeader *message) |
279 | { | 280 | { |
280 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 281 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
281 | "Core provides inbound data from `%4s'.\n", GNUNET_i2s (other)); | 282 | "Core provides inbound data from `%s'.\n", GNUNET_i2s (other)); |
282 | return GNUNET_OK; | 283 | return GNUNET_OK; |
283 | } | 284 | } |
284 | 285 | ||
@@ -288,7 +289,7 @@ outbound_notify (void *cls, const struct GNUNET_PeerIdentity *other, | |||
288 | const struct GNUNET_MessageHeader *message) | 289 | const struct GNUNET_MessageHeader *message) |
289 | { | 290 | { |
290 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 291 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
291 | "Core notifies about outbound data for `%4s'.\n", | 292 | "Core notifies about outbound data for `%s'.\n", |
292 | GNUNET_i2s (other)); | 293 | GNUNET_i2s (other)); |
293 | return GNUNET_OK; | 294 | return GNUNET_OK; |
294 | } | 295 | } |
@@ -299,7 +300,8 @@ transmit_ready (void *cls, size_t size, void *buf); | |||
299 | 300 | ||
300 | 301 | ||
301 | static int | 302 | static int |
302 | process_mtype (void *cls, const struct GNUNET_PeerIdentity *peer, | 303 | process_mtype (void *cls, |
304 | const struct GNUNET_PeerIdentity *peer, | ||
303 | const struct GNUNET_MessageHeader *message) | 305 | const struct GNUNET_MessageHeader *message) |
304 | { | 306 | { |
305 | static int n; | 307 | static int n; |
@@ -342,9 +344,11 @@ process_mtype (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
342 | { | 344 | { |
343 | if (n == tr_n) | 345 | if (n == tr_n) |
344 | GNUNET_break (NULL != | 346 | GNUNET_break (NULL != |
345 | GNUNET_CORE_notify_transmit_ready (p1.ch, GNUNET_NO, | 347 | GNUNET_CORE_notify_transmit_ready (p1.ch, |
348 | GNUNET_NO /* no cork */, | ||
346 | GNUNET_CORE_PRIO_BEST_EFFORT, | 349 | GNUNET_CORE_PRIO_BEST_EFFORT, |
347 | FAST_TIMEOUT, &p2.id, | 350 | FAST_TIMEOUT /* ignored! */, |
351 | &p2.id, | ||
348 | get_size (tr_n), | 352 | get_size (tr_n), |
349 | &transmit_ready, &p1)); | 353 | &transmit_ready, &p1)); |
350 | } | 354 | } |
@@ -365,7 +369,7 @@ init_notify (void *cls, | |||
365 | struct PeerContext *p = cls; | 369 | struct PeerContext *p = cls; |
366 | 370 | ||
367 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 371 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
368 | "Connection to CORE service of `%4s' established\n", | 372 | "Connection to CORE service of `%s' established\n", |
369 | GNUNET_i2s (my_identity)); | 373 | GNUNET_i2s (my_identity)); |
370 | p->id = *my_identity; | 374 | p->id = *my_identity; |
371 | if (cls == &p1) | 375 | if (cls == &p1) |
@@ -373,9 +377,13 @@ init_notify (void *cls, | |||
373 | GNUNET_assert (ok == 2); | 377 | GNUNET_assert (ok == 2); |
374 | OKPP; | 378 | OKPP; |
375 | /* connect p2 */ | 379 | /* connect p2 */ |
376 | GNUNET_assert (NULL != (p2.ch = GNUNET_CORE_connect (p2.cfg, &p2, &init_notify, &connect_notify, | 380 | GNUNET_assert (NULL != (p2.ch = GNUNET_CORE_connect (p2.cfg, &p2, |
377 | &disconnect_notify, &inbound_notify, GNUNET_YES, | 381 | &init_notify, |
378 | &outbound_notify, GNUNET_YES, handlers))); | 382 | &connect_notify, |
383 | &disconnect_notify, | ||
384 | &inbound_notify, GNUNET_YES, | ||
385 | &outbound_notify, GNUNET_YES, | ||
386 | handlers))); | ||
379 | } | 387 | } |
380 | else | 388 | else |
381 | { | 389 | { |
@@ -383,7 +391,7 @@ init_notify (void *cls, | |||
383 | OKPP; | 391 | OKPP; |
384 | GNUNET_assert (cls == &p2); | 392 | GNUNET_assert (cls == &p2); |
385 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 393 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
386 | "Asking transport (1) to connect to peer `%4s'\n", | 394 | "Asking transport (1) to connect to peer `%s'\n", |
387 | GNUNET_i2s (&p2.id)); | 395 | GNUNET_i2s (&p2.id)); |
388 | connect_task = GNUNET_SCHEDULER_add_now (&try_connect, NULL); | 396 | connect_task = GNUNET_SCHEDULER_add_now (&try_connect, NULL); |
389 | } | 397 | } |
@@ -443,9 +451,13 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
443 | err_task = | 451 | err_task = |
444 | GNUNET_SCHEDULER_add_delayed (TIMEOUT, &terminate_task_error, NULL); | 452 | GNUNET_SCHEDULER_add_delayed (TIMEOUT, &terminate_task_error, NULL); |
445 | 453 | ||
446 | GNUNET_assert (NULL != (p1.ch = GNUNET_CORE_connect (p1.cfg, &p1, &init_notify, &connect_notify, | 454 | GNUNET_assert (NULL != (p1.ch = GNUNET_CORE_connect (p1.cfg, &p1, |
447 | &disconnect_notify, &inbound_notify, GNUNET_YES, | 455 | &init_notify, |
448 | &outbound_notify, GNUNET_YES, handlers))); | 456 | &connect_notify, |
457 | &disconnect_notify, | ||
458 | &inbound_notify, GNUNET_YES, | ||
459 | &outbound_notify, GNUNET_YES, | ||
460 | handlers))); | ||
449 | } | 461 | } |
450 | 462 | ||
451 | 463 | ||
@@ -476,7 +488,7 @@ main (int argc, char *argv1[]) | |||
476 | GNUNET_GETOPT_OPTION_END | 488 | GNUNET_GETOPT_OPTION_END |
477 | }; | 489 | }; |
478 | ok = 1; | 490 | ok = 1; |
479 | GNUNET_log_setup ("test-core-api", | 491 | GNUNET_log_setup ("test-core-api-reliability", |
480 | "WARNING", | 492 | "WARNING", |
481 | NULL); | 493 | NULL); |
482 | GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, argv, | 494 | GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, argv, |