diff options
Diffstat (limited to 'src/transport/gnunet-service-transport.c')
-rw-r--r-- | src/transport/gnunet-service-transport.c | 37 |
1 files changed, 34 insertions, 3 deletions
diff --git a/src/transport/gnunet-service-transport.c b/src/transport/gnunet-service-transport.c index 427b8dabd..2e90bcf3e 100644 --- a/src/transport/gnunet-service-transport.c +++ b/src/transport/gnunet-service-transport.c | |||
@@ -1218,6 +1218,11 @@ static struct GNUNET_CONTAINER_MultiHashMap *validation_map; | |||
1218 | static struct GNUNET_STATISTICS_Handle *stats; | 1218 | static struct GNUNET_STATISTICS_Handle *stats; |
1219 | 1219 | ||
1220 | /** | 1220 | /** |
1221 | * Identifier of 'refresh_hello' task. | ||
1222 | */ | ||
1223 | static GNUNET_SCHEDULER_TaskIdentifier hello_task; | ||
1224 | |||
1225 | /** | ||
1221 | * Is transport service shutting down ? | 1226 | * Is transport service shutting down ? |
1222 | */ | 1227 | */ |
1223 | static int shutdown_in_progress; | 1228 | static int shutdown_in_progress; |
@@ -2448,15 +2453,20 @@ address_generator (void *cls, size_t max, void *buf) | |||
2448 | /** | 2453 | /** |
2449 | * Construct our HELLO message from all of the addresses of | 2454 | * Construct our HELLO message from all of the addresses of |
2450 | * all of the transports. | 2455 | * all of the transports. |
2456 | * | ||
2457 | * @param cls unused | ||
2458 | * @param tc scheduler context | ||
2451 | */ | 2459 | */ |
2452 | static void | 2460 | static void |
2453 | refresh_hello () | 2461 | refresh_hello_task (void *cls, |
2462 | const struct GNUNET_SCHEDULER_TaskContext *tc) | ||
2454 | { | 2463 | { |
2455 | struct GNUNET_HELLO_Message *hello; | 2464 | struct GNUNET_HELLO_Message *hello; |
2456 | struct TransportClient *cpos; | 2465 | struct TransportClient *cpos; |
2457 | struct NeighbourList *npos; | 2466 | struct NeighbourList *npos; |
2458 | struct GeneratorContext gc; | 2467 | struct GeneratorContext gc; |
2459 | 2468 | ||
2469 | hello_task = GNUNET_SCHEDULER_NO_TASK; | ||
2460 | gc.plug_pos = plugins; | 2470 | gc.plug_pos = plugins; |
2461 | gc.addr_pos = plugins != NULL ? plugins->addresses : NULL; | 2471 | gc.addr_pos = plugins != NULL ? plugins->addresses : NULL; |
2462 | gc.expiration = GNUNET_TIME_relative_to_absolute (HELLO_ADDRESS_EXPIRATION); | 2472 | gc.expiration = GNUNET_TIME_relative_to_absolute (HELLO_ADDRESS_EXPIRATION); |
@@ -2504,6 +2514,21 @@ refresh_hello () | |||
2504 | 2514 | ||
2505 | 2515 | ||
2506 | /** | 2516 | /** |
2517 | * Schedule task to refresh hello (unless such a | ||
2518 | * task exists already). | ||
2519 | */ | ||
2520 | static void | ||
2521 | refresh_hello () | ||
2522 | { | ||
2523 | if (hello_task != GNUNET_SCHEDULER_NO_TASK) | ||
2524 | return; | ||
2525 | hello_task | ||
2526 | = GNUNET_SCHEDULER_add_now (&refresh_hello_task, | ||
2527 | NULL); | ||
2528 | } | ||
2529 | |||
2530 | |||
2531 | /** | ||
2507 | * Iterator over hash map entries that NULLs the session of validation | 2532 | * Iterator over hash map entries that NULLs the session of validation |
2508 | * entries that match the given session. | 2533 | * entries that match the given session. |
2509 | * | 2534 | * |
@@ -4548,7 +4573,7 @@ transmit_hello_and_ping (void *cls, | |||
4548 | return; | 4573 | return; |
4549 | } | 4574 | } |
4550 | if (NULL == our_hello) | 4575 | if (NULL == our_hello) |
4551 | refresh_hello (); | 4576 | refresh_hello_task (NULL, NULL); |
4552 | hello_size = GNUNET_HELLO_size(our_hello); | 4577 | hello_size = GNUNET_HELLO_size(our_hello); |
4553 | slen = strlen(va->transport_name) + 1; | 4578 | slen = strlen(va->transport_name) + 1; |
4554 | tsize = sizeof(struct TransportPingMessage) + hello_size + va->addrlen + slen; | 4579 | tsize = sizeof(struct TransportPingMessage) + hello_size + va->addrlen + slen; |
@@ -6302,6 +6327,11 @@ shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
6302 | GNUNET_PEERINFO_disconnect (peerinfo); | 6327 | GNUNET_PEERINFO_disconnect (peerinfo); |
6303 | peerinfo = NULL; | 6328 | peerinfo = NULL; |
6304 | } | 6329 | } |
6330 | if (GNUNET_SCHEDULER_NO_TASK != hello_task) | ||
6331 | { | ||
6332 | GNUNET_SCHEDULER_cancel (hello_task); | ||
6333 | hello_task = GNUNET_SCHEDULER_NO_TASK; | ||
6334 | } | ||
6305 | /* Can we assume those are gone by now, or do we need to clean up | 6335 | /* Can we assume those are gone by now, or do we need to clean up |
6306 | explicitly!? */ | 6336 | explicitly!? */ |
6307 | GNUNET_break (bl_head == NULL); | 6337 | GNUNET_break (bl_head == NULL); |
@@ -7743,7 +7773,8 @@ run (void *cls, | |||
7743 | ats_init(); | 7773 | ats_init(); |
7744 | 7774 | ||
7745 | #if DEBUG_TRANSPORT | 7775 | #if DEBUG_TRANSPORT |
7746 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, _("Transport service ready.\n")); | 7776 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
7777 | _("Transport service ready.\n")); | ||
7747 | #endif | 7778 | #endif |
7748 | /* If we have a blacklist file, read from it */ | 7779 | /* If we have a blacklist file, read from it */ |
7749 | read_blacklist_file(cfg); | 7780 | read_blacklist_file(cfg); |