diff options
author | Christian Grothoff <christian@grothoff.org> | 2011-05-12 16:39:03 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2011-05-12 16:39:03 +0000 |
commit | ce1136b52a46d90dff7618a3ec0504085f1cf6a4 (patch) | |
tree | f12a7df0065a1a330bbb61f8c7e35ff22757b05c /src/transport | |
parent | 1bd2d5220b3483c6e6eeed3f5c9017e44612826f (diff) | |
download | gnunet-ce1136b52a46d90dff7618a3ec0504085f1cf6a4.tar.gz gnunet-ce1136b52a46d90dff7618a3ec0504085f1cf6a4.zip |
fixing bug with connections that go down not coming back up
Diffstat (limited to 'src/transport')
-rw-r--r-- | src/transport/gnunet-service-transport.c | 197 | ||||
-rw-r--r-- | src/transport/plugin_transport_tcp.c | 10 | ||||
-rw-r--r-- | src/transport/transport.h | 2 |
3 files changed, 168 insertions, 41 deletions
diff --git a/src/transport/gnunet-service-transport.c b/src/transport/gnunet-service-transport.c index 0c668712e..158499407 100644 --- a/src/transport/gnunet-service-transport.c +++ b/src/transport/gnunet-service-transport.c | |||
@@ -1323,15 +1323,18 @@ static int update_addr_value (struct ForeignAddressList *fal, uint32_t value , i | |||
1323 | return set; | 1323 | return set; |
1324 | } | 1324 | } |
1325 | 1325 | ||
1326 | static int update_addr_ats (struct ForeignAddressList *fal, const struct GNUNET_TRANSPORT_ATS_Information *ats_data, int ats_count) | 1326 | static int |
1327 | update_addr_ats (struct ForeignAddressList *fal, | ||
1328 | const struct GNUNET_TRANSPORT_ATS_Information *ats_data, | ||
1329 | int ats_count) | ||
1327 | { | 1330 | { |
1328 | int c1, set; | 1331 | int c1, set; |
1329 | set = GNUNET_NO; | 1332 | set = GNUNET_NO; |
1330 | for (c1=0; c1<ats_count; c1++) | 1333 | for (c1=0; c1<ats_count; c1++) |
1331 | { | 1334 | { |
1332 | set = update_addr_value(fal, ntohl(ats_data[c1].value), ntohl(ats_data[c1].type)); | 1335 | set = update_addr_value(fal, ntohl(ats_data[c1].value), ntohl(ats_data[c1].type)); |
1333 | } | 1336 | } |
1334 | return set; | 1337 | return set; |
1335 | } | 1338 | } |
1336 | 1339 | ||
1337 | /** | 1340 | /** |
@@ -1380,13 +1383,20 @@ is_blacklisted (const struct GNUNET_PeerIdentity *peer, struct TransportPlugin * | |||
1380 | 1383 | ||
1381 | 1384 | ||
1382 | static void | 1385 | static void |
1383 | add_peer_to_blacklist (struct GNUNET_PeerIdentity *peer, char *transport_name) | 1386 | add_peer_to_blacklist (struct GNUNET_PeerIdentity *peer, |
1387 | char *transport_name) | ||
1384 | { | 1388 | { |
1385 | struct TransportPlugin *plugin; | 1389 | struct TransportPlugin *plugin; |
1386 | 1390 | ||
1387 | plugin = find_transport(transport_name); | 1391 | plugin = find_transport(transport_name); |
1388 | if (plugin == NULL) /* Nothing to do */ | 1392 | if (plugin == NULL) /* Nothing to do */ |
1389 | return; | 1393 | return; |
1394 | #if DEBUG_TRANSPORT | ||
1395 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
1396 | "Adding peer `%s' with plugin `%s' to blacklist\n", | ||
1397 | GNUNET_i2s (peer), | ||
1398 | transport_name); | ||
1399 | #endif | ||
1390 | if (plugin->blacklist == NULL) | 1400 | if (plugin->blacklist == NULL) |
1391 | plugin->blacklist = GNUNET_CONTAINER_multihashmap_create(TRANSPORT_BLACKLIST_HT_SIZE); | 1401 | plugin->blacklist = GNUNET_CONTAINER_multihashmap_create(TRANSPORT_BLACKLIST_HT_SIZE); |
1392 | GNUNET_assert(plugin->blacklist != NULL); | 1402 | GNUNET_assert(plugin->blacklist != NULL); |
@@ -2449,6 +2459,8 @@ try_fast_reconnect (struct TransportPlugin *p, | |||
2449 | struct NeighbourList *nl) | 2459 | struct NeighbourList *nl) |
2450 | { | 2460 | { |
2451 | /* FIXME-MW: fast reconnect / transport switching not implemented... */ | 2461 | /* FIXME-MW: fast reconnect / transport switching not implemented... */ |
2462 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | ||
2463 | "try_fast_reconnect not implemented!\n"); | ||
2452 | /* Note: the idea here is to hide problems with transports (or | 2464 | /* Note: the idea here is to hide problems with transports (or |
2453 | switching between plugins) from the core to eliminate the need to | 2465 | switching between plugins) from the core to eliminate the need to |
2454 | re-negotiate session keys and the like; OTOH, we should tell core | 2466 | re-negotiate session keys and the like; OTOH, we should tell core |
@@ -2482,9 +2494,11 @@ try_fast_reconnect (struct TransportPlugin *p, | |||
2482 | */ | 2494 | */ |
2483 | 2495 | ||
2484 | /* No reconnect, signal disconnect instead! */ | 2496 | /* No reconnect, signal disconnect instead! */ |
2497 | #if DEBUG_TRANSPORT | ||
2485 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 2498 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
2486 | "Disconnecting peer `%4s', %s\n", GNUNET_i2s(&nl->id), | 2499 | "Disconnecting peer `%4s', %s\n", GNUNET_i2s(&nl->id), |
2487 | "try_fast_reconnect"); | 2500 | "try_fast_reconnect"); |
2501 | #endif | ||
2488 | disconnect_neighbour (nl, GNUNET_YES); | 2502 | disconnect_neighbour (nl, GNUNET_YES); |
2489 | } | 2503 | } |
2490 | 2504 | ||
@@ -2511,12 +2525,25 @@ plugin_env_session_end (void *cls, | |||
2511 | struct ForeignAddressList *pos; | 2525 | struct ForeignAddressList *pos; |
2512 | struct ForeignAddressList *prev; | 2526 | struct ForeignAddressList *prev; |
2513 | 2527 | ||
2528 | #if DEBUG_TRANSPORT | ||
2529 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
2530 | "Session ended with peer `%4s', %s\n", | ||
2531 | GNUNET_i2s(&nl->id), | ||
2532 | "plugin_env_session_end"); | ||
2533 | #endif | ||
2514 | GNUNET_CONTAINER_multihashmap_iterate (validation_map, | 2534 | GNUNET_CONTAINER_multihashmap_iterate (validation_map, |
2515 | &remove_session_validations, | 2535 | &remove_session_validations, |
2516 | session); | 2536 | session); |
2517 | nl = find_neighbour (peer); | 2537 | nl = find_neighbour (peer); |
2518 | if (nl == NULL) | 2538 | if (nl == NULL) |
2519 | return; /* was never marked as connected */ | 2539 | { |
2540 | #if DEBUG_TRANSPORT | ||
2541 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
2542 | "No neighbour record found for peer `%4s'\n", | ||
2543 | GNUNET_i2s(&nl->id)); | ||
2544 | #endif | ||
2545 | return; /* was never marked as connected */ | ||
2546 | } | ||
2520 | rl = nl->plugins; | 2547 | rl = nl->plugins; |
2521 | while (rl != NULL) | 2548 | while (rl != NULL) |
2522 | { | 2549 | { |
@@ -2525,7 +2552,15 @@ plugin_env_session_end (void *cls, | |||
2525 | rl = rl->next; | 2552 | rl = rl->next; |
2526 | } | 2553 | } |
2527 | if (rl == NULL) | 2554 | if (rl == NULL) |
2528 | return; /* was never marked as connected */ | 2555 | { |
2556 | #if DEBUG_TRANSPORT | ||
2557 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
2558 | "Plugin was associated with peer `%4s'\n", | ||
2559 | GNUNET_i2s(&nl->id)); | ||
2560 | #endif | ||
2561 | disconnect_neighbour (nl, GNUNET_YES); | ||
2562 | return; | ||
2563 | } | ||
2529 | prev = NULL; | 2564 | prev = NULL; |
2530 | pos = rl->addresses; | 2565 | pos = rl->addresses; |
2531 | while ( (pos != NULL) && | 2566 | while ( (pos != NULL) && |
@@ -2535,12 +2570,22 @@ plugin_env_session_end (void *cls, | |||
2535 | pos = pos->next; | 2570 | pos = pos->next; |
2536 | } | 2571 | } |
2537 | if (pos == NULL) | 2572 | if (pos == NULL) |
2538 | return; /* was never marked as connected */ | 2573 | { |
2574 | #if DEBUG_TRANSPORT | ||
2575 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
2576 | "Session was never marked as ready for peer `%4s'\n", | ||
2577 | GNUNET_i2s(&nl->id)); | ||
2578 | #endif | ||
2579 | disconnect_neighbour (nl, GNUNET_YES); | ||
2580 | return; /* was never marked as connected */ | ||
2581 | } | ||
2539 | pos->session = NULL; | 2582 | pos->session = NULL; |
2540 | if (pos->addrlen != 0) | 2583 | if (pos->addrlen != 0) |
2541 | { | 2584 | { |
2542 | if (nl->received_pong != GNUNET_NO) | 2585 | if (nl->received_pong != GNUNET_NO) |
2543 | try_fast_reconnect (p, nl); | 2586 | try_fast_reconnect (p, nl); |
2587 | else | ||
2588 | disconnect_neighbour (nl, GNUNET_YES); | ||
2544 | return; | 2589 | return; |
2545 | } | 2590 | } |
2546 | /* was inbound connection, free 'pos' */ | 2591 | /* was inbound connection, free 'pos' */ |
@@ -2558,7 +2603,10 @@ plugin_env_session_end (void *cls, | |||
2558 | GNUNET_free (pos); | 2603 | GNUNET_free (pos); |
2559 | ats->stat.recreate_problem = GNUNET_YES; | 2604 | ats->stat.recreate_problem = GNUNET_YES; |
2560 | if (nl->received_pong == GNUNET_NO) | 2605 | if (nl->received_pong == GNUNET_NO) |
2561 | return; /* nothing to do, never connected... */ | 2606 | { |
2607 | disconnect_neighbour (nl, GNUNET_YES); | ||
2608 | return; /* nothing to do, never connected... */ | ||
2609 | } | ||
2562 | /* check if we have any validated addresses left */ | 2610 | /* check if we have any validated addresses left */ |
2563 | pos = rl->addresses; | 2611 | pos = rl->addresses; |
2564 | while (pos != NULL) | 2612 | while (pos != NULL) |
@@ -2572,12 +2620,15 @@ plugin_env_session_end (void *cls, | |||
2572 | } | 2620 | } |
2573 | /* no valid addresses left, signal disconnect! */ | 2621 | /* no valid addresses left, signal disconnect! */ |
2574 | 2622 | ||
2623 | #if DEBUG_TRANSPORT | ||
2575 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 2624 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
2576 | "Disconnecting peer `%4s', %s\n", GNUNET_i2s(&nl->id), | 2625 | "Disconnecting peer `%4s', %s\n", |
2577 | "plugin_env_session_end"); | 2626 | GNUNET_i2s(&nl->id), |
2627 | "plugin_env_session_end"); | ||
2628 | #endif | ||
2578 | /* FIXME: This doesn't mean there are no addresses left for this PEER, | 2629 | /* FIXME: This doesn't mean there are no addresses left for this PEER, |
2579 | * it means there aren't any left for this PLUGIN/PEER combination! So | 2630 | * it means there aren't any left for this PLUGIN/PEER combination! So |
2580 | * calling disconnect_neighbor here with GNUNET_NO forces disconnect | 2631 | * calling disconnect_neighbour here with GNUNET_NO forces disconnect |
2581 | * when it isn't necessary. Using GNUNET_YES at least checks to see | 2632 | * when it isn't necessary. Using GNUNET_YES at least checks to see |
2582 | * if there are any addresses that work first, so as not to overdo it. | 2633 | * if there are any addresses that work first, so as not to overdo it. |
2583 | * --NE | 2634 | * --NE |
@@ -3151,9 +3202,11 @@ add_to_foreign_address_list (void *cls, | |||
3151 | } | 3202 | } |
3152 | if (fal == NULL) | 3203 | if (fal == NULL) |
3153 | { | 3204 | { |
3205 | #if DEBUG_TRANSPORT | ||
3154 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 3206 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
3155 | "Failed to add new address for `%4s'\n", | 3207 | "Failed to add new address for `%4s'\n", |
3156 | GNUNET_i2s (&n->id)); | 3208 | GNUNET_i2s (&n->id)); |
3209 | #endif | ||
3157 | return GNUNET_OK; | 3210 | return GNUNET_OK; |
3158 | } | 3211 | } |
3159 | if (fal->validated == GNUNET_NO) | 3212 | if (fal->validated == GNUNET_NO) |
@@ -3166,8 +3219,10 @@ add_to_foreign_address_list (void *cls, | |||
3166 | } | 3219 | } |
3167 | if (try == GNUNET_YES) | 3220 | if (try == GNUNET_YES) |
3168 | { | 3221 | { |
3222 | #if DEBUG_TRANSPORT | ||
3169 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 3223 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
3170 | "Have new addresses, will try to trigger transmissions.\n"); | 3224 | "Have new addresses, will try to trigger transmissions.\n"); |
3225 | #endif | ||
3171 | try_transmission_to_peer (n); | 3226 | try_transmission_to_peer (n); |
3172 | } | 3227 | } |
3173 | return GNUNET_OK; | 3228 | return GNUNET_OK; |
@@ -3192,12 +3247,15 @@ add_hello_for_peer (void *cls, | |||
3192 | struct NeighbourList *n = cls; | 3247 | struct NeighbourList *n = cls; |
3193 | 3248 | ||
3194 | if (err_msg != NULL) | 3249 | if (err_msg != NULL) |
3195 | { | 3250 | { |
3196 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 3251 | #if DEBUG_TRANSPORT |
3197 | _("Error in communication with PEERINFO service\n")); | 3252 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
3198 | /* return; */ | 3253 | _("Error in communication with PEERINFO service: %s\n"), |
3199 | } | 3254 | err_msg); |
3200 | if ((peer == NULL)) | 3255 | #endif |
3256 | /* return; */ | ||
3257 | } | ||
3258 | if (peer == NULL) | ||
3201 | { | 3259 | { |
3202 | GNUNET_STATISTICS_update (stats, | 3260 | GNUNET_STATISTICS_update (stats, |
3203 | gettext_noop ("# outstanding peerinfo iterate requests"), | 3261 | gettext_noop ("# outstanding peerinfo iterate requests"), |
@@ -3457,8 +3515,16 @@ transmit_blacklist_message (void *cls, | |||
3457 | GNUNET_assert (bc->task == GNUNET_SCHEDULER_NO_TASK); | 3515 | GNUNET_assert (bc->task == GNUNET_SCHEDULER_NO_TASK); |
3458 | bc->task = GNUNET_SCHEDULER_add_now (&do_blacklist_check, | 3516 | bc->task = GNUNET_SCHEDULER_add_now (&do_blacklist_check, |
3459 | bc); | 3517 | bc); |
3518 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | ||
3519 | "Failed to send blacklist test for peer `%s' to client\n", | ||
3520 | GNUNET_i2s (&bc->peer)); | ||
3460 | return 0; | 3521 | return 0; |
3461 | } | 3522 | } |
3523 | #if DEBUG_TRANSPORT | ||
3524 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
3525 | "Sending blacklist test for peer `%s' to client\n", | ||
3526 | GNUNET_i2s (&bc->peer)); | ||
3527 | #endif | ||
3462 | bl = bc->bl_pos; | 3528 | bl = bc->bl_pos; |
3463 | bm.header.size = htons (sizeof (struct BlacklistMessage)); | 3529 | bm.header.size = htons (sizeof (struct BlacklistMessage)); |
3464 | bm.header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_BLACKLIST_QUERY); | 3530 | bm.header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_BLACKLIST_QUERY); |
@@ -3487,6 +3553,11 @@ do_blacklist_check (void *cls, | |||
3487 | bl = bc->bl_pos; | 3553 | bl = bc->bl_pos; |
3488 | if (bl == NULL) | 3554 | if (bl == NULL) |
3489 | { | 3555 | { |
3556 | #if DEBUG_TRANSPORT | ||
3557 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
3558 | "No blacklist clients active, will now setup neighbour record for peer `%s'\n", | ||
3559 | GNUNET_i2s (&bc->peer)); | ||
3560 | #endif | ||
3490 | bc->cont (bc->cont_cls, | 3561 | bc->cont (bc->cont_cls, |
3491 | setup_new_neighbour (&bc->peer, bc->do_hello)); | 3562 | setup_new_neighbour (&bc->peer, bc->do_hello)); |
3492 | GNUNET_free (bc); | 3563 | GNUNET_free (bc); |
@@ -3528,6 +3599,11 @@ setup_peer_check_blacklist (const struct GNUNET_PeerIdentity *peer, | |||
3528 | n = find_neighbour(peer); | 3599 | n = find_neighbour(peer); |
3529 | if (n != NULL) | 3600 | if (n != NULL) |
3530 | { | 3601 | { |
3602 | #if DEBUG_TRANSPORT | ||
3603 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | ||
3604 | "Neighbour record exists for peer `%s'\n", | ||
3605 | GNUNET_i2s(peer)); | ||
3606 | #endif | ||
3531 | if (cont != NULL) | 3607 | if (cont != NULL) |
3532 | cont (cont_cls, n); | 3608 | cont (cont_cls, n); |
3533 | return; | 3609 | return; |
@@ -3567,9 +3643,11 @@ confirm_or_drop_neighbour (void *cls, | |||
3567 | 3643 | ||
3568 | if (n == NULL) | 3644 | if (n == NULL) |
3569 | { | 3645 | { |
3646 | #if DEBUG_TRANSPORT | ||
3570 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 3647 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
3571 | "Disconnecting peer `%4s', %s\n", GNUNET_i2s(&orig->id), | 3648 | "Disconnecting peer `%4s', %s\n", GNUNET_i2s(&orig->id), |
3572 | "confirm_or_drop_neighboUr"); | 3649 | "confirm_or_drop_neighboUr"); |
3650 | #endif | ||
3573 | disconnect_neighbour (orig, GNUNET_NO); | 3651 | disconnect_neighbour (orig, GNUNET_NO); |
3574 | } | 3652 | } |
3575 | } | 3653 | } |
@@ -3648,6 +3726,11 @@ handle_blacklist_reply (void *cls, | |||
3648 | bl = bl->next; | 3726 | bl = bl->next; |
3649 | if (bl == NULL) | 3727 | if (bl == NULL) |
3650 | { | 3728 | { |
3729 | #if DEBUG_TRANSPORT | ||
3730 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
3731 | "Blacklist client disconnected\n"); | ||
3732 | #endif | ||
3733 | /* FIXME: other error handling here!? */ | ||
3651 | GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); | 3734 | GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); |
3652 | return; | 3735 | return; |
3653 | } | 3736 | } |
@@ -3655,12 +3738,20 @@ handle_blacklist_reply (void *cls, | |||
3655 | bl->bc = NULL; | 3738 | bl->bc = NULL; |
3656 | if (ntohl (msg->is_allowed) == GNUNET_SYSERR) | 3739 | if (ntohl (msg->is_allowed) == GNUNET_SYSERR) |
3657 | { | 3740 | { |
3741 | #if DEBUG_TRANSPORT | ||
3742 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
3743 | "Blacklist check failed, peer not allowed\n"); | ||
3744 | #endif | ||
3658 | bc->cont (bc->cont_cls, NULL); | 3745 | bc->cont (bc->cont_cls, NULL); |
3659 | GNUNET_CONTAINER_DLL_remove (bc_head, bc_tail, bc); | 3746 | GNUNET_CONTAINER_DLL_remove (bc_head, bc_tail, bc); |
3660 | GNUNET_free (bc); | 3747 | GNUNET_free (bc); |
3661 | } | 3748 | } |
3662 | else | 3749 | else |
3663 | { | 3750 | { |
3751 | #if DEBUG_TRANSPORT | ||
3752 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
3753 | "Blacklist check succeeded, continuing with checks\n"); | ||
3754 | #endif | ||
3664 | bc->bl_pos = bc->bl_pos->next; | 3755 | bc->bl_pos = bc->bl_pos->next; |
3665 | bc->task = GNUNET_SCHEDULER_add_now (&do_blacklist_check, | 3756 | bc->task = GNUNET_SCHEDULER_add_now (&do_blacklist_check, |
3666 | bc); | 3757 | bc); |
@@ -3905,11 +3996,13 @@ handle_payload_message (const struct GNUNET_MessageHeader *message, | |||
3905 | msize = ntohs (message->size); | 3996 | msize = ntohs (message->size); |
3906 | if (n->received_pong == GNUNET_NO) | 3997 | if (n->received_pong == GNUNET_NO) |
3907 | { | 3998 | { |
3999 | #if DEBUG_TRANSPORT | ||
3908 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 4000 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
3909 | "Received message of type %u and size %u from `%4s', but no pong yet!!\n", | 4001 | "Received message of type %u and size %u from `%4s', but no pong yet!!\n", |
3910 | ntohs (message->type), | 4002 | ntohs (message->type), |
3911 | ntohs (message->size), | 4003 | ntohs (message->size), |
3912 | GNUNET_i2s (&n->id)); | 4004 | GNUNET_i2s (&n->id)); |
4005 | #endif | ||
3913 | GNUNET_free_non_null (n->pre_connect_message_buffer); | 4006 | GNUNET_free_non_null (n->pre_connect_message_buffer); |
3914 | n->pre_connect_message_buffer = GNUNET_malloc (msize); | 4007 | n->pre_connect_message_buffer = GNUNET_malloc (msize); |
3915 | memcpy (n->pre_connect_message_buffer, message, msize); | 4008 | memcpy (n->pre_connect_message_buffer, message, msize); |
@@ -4078,8 +4171,12 @@ check_pending_validation (void *cls, | |||
4078 | { | 4171 | { |
4079 | char * peer; | 4172 | char * peer; |
4080 | GNUNET_asprintf(&peer, "%s",GNUNET_i2s (&pong->pid)); | 4173 | GNUNET_asprintf(&peer, "%s",GNUNET_i2s (&pong->pid)); |
4174 | #if DEBUG_TRANSPORT | ||
4081 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 4175 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
4082 | "Received PONG for different identity: I am `%s', PONG identity: `%s'\n",GNUNET_i2s (&my_identity), peer ); | 4176 | "Received PONG for different identity: I am `%s', PONG identity: `%s'\n", |
4177 | GNUNET_i2s (&my_identity), | ||
4178 | peer ); | ||
4179 | #endif | ||
4083 | GNUNET_free (peer); | 4180 | GNUNET_free (peer); |
4084 | return GNUNET_NO; | 4181 | return GNUNET_NO; |
4085 | } | 4182 | } |
@@ -4529,10 +4626,13 @@ check_hello_validated (void *cls, | |||
4529 | struct NeighbourList *n; | 4626 | struct NeighbourList *n; |
4530 | 4627 | ||
4531 | if (err_msg != NULL) | 4628 | if (err_msg != NULL) |
4532 | { | 4629 | { |
4533 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 4630 | #if DEBUG_TRANSPORT |
4534 | _("Error in communication with PEERINFO service\n")); | 4631 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
4535 | /* return; */ | 4632 | _("Error in communication with PEERINFO service: %s\n"), |
4633 | err_msg); | ||
4634 | #endif | ||
4635 | /* return; */ | ||
4536 | } | 4636 | } |
4537 | 4637 | ||
4538 | if (peer == NULL) | 4638 | if (peer == NULL) |
@@ -4748,6 +4848,7 @@ process_hello (struct TransportPlugin *plugin, | |||
4748 | if (plugin != NULL) | 4848 | if (plugin != NULL) |
4749 | { | 4849 | { |
4750 | my_id = GNUNET_strdup(GNUNET_i2s(plugin->env.my_identity)); | 4850 | my_id = GNUNET_strdup(GNUNET_i2s(plugin->env.my_identity)); |
4851 | #if DEBUG_TRANSPORT | ||
4751 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 4852 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
4752 | "%s: Starting validation of `%s' message for `%4s' via '%s' of size %u\n", | 4853 | "%s: Starting validation of `%s' message for `%4s' via '%s' of size %u\n", |
4753 | my_id, | 4854 | my_id, |
@@ -4755,6 +4856,7 @@ process_hello (struct TransportPlugin *plugin, | |||
4755 | GNUNET_i2s (&target), | 4856 | GNUNET_i2s (&target), |
4756 | plugin->short_name, | 4857 | plugin->short_name, |
4757 | GNUNET_HELLO_size(hello)); | 4858 | GNUNET_HELLO_size(hello)); |
4859 | #endif | ||
4758 | GNUNET_free(my_id); | 4860 | GNUNET_free(my_id); |
4759 | } | 4861 | } |
4760 | #endif | 4862 | #endif |
@@ -4816,9 +4918,11 @@ disconnect_neighbour (struct NeighbourList *n, int check) | |||
4816 | { | 4918 | { |
4817 | if (GNUNET_YES == peer_addresses->connected) | 4919 | if (GNUNET_YES == peer_addresses->connected) |
4818 | { | 4920 | { |
4921 | #if DEBUG_TRANSPORT | ||
4819 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 4922 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
4820 | "NOT Disconnecting from `%4s', still have live addresses!\n", | 4923 | "NOT Disconnecting from `%4s', still have live addresses!\n", |
4821 | GNUNET_i2s (&n->id)); | 4924 | GNUNET_i2s (&n->id)); |
4925 | #endif | ||
4822 | return; /* still connected */ | 4926 | return; /* still connected */ |
4823 | } | 4927 | } |
4824 | peer_addresses = peer_addresses->next; | 4928 | peer_addresses = peer_addresses->next; |
@@ -4873,12 +4977,12 @@ disconnect_neighbour (struct NeighbourList *n, int check) | |||
4873 | GNUNET_SCHEDULER_cancel (peer_pos->revalidate_task); | 4977 | GNUNET_SCHEDULER_cancel (peer_pos->revalidate_task); |
4874 | peer_pos->revalidate_task = GNUNET_SCHEDULER_NO_TASK; | 4978 | peer_pos->revalidate_task = GNUNET_SCHEDULER_NO_TASK; |
4875 | } | 4979 | } |
4876 | GNUNET_free(peer_pos->ressources); | 4980 | GNUNET_free(peer_pos->ressources); |
4877 | peer_pos->ressources = NULL; | 4981 | peer_pos->ressources = NULL; |
4878 | GNUNET_free(peer_pos->quality); | 4982 | GNUNET_free(peer_pos->quality); |
4879 | peer_pos->ressources = NULL; | 4983 | peer_pos->ressources = NULL; |
4880 | GNUNET_free(peer_pos); | 4984 | GNUNET_free(peer_pos); |
4881 | ats->stat.recreate_problem = GNUNET_YES; | 4985 | ats->stat.recreate_problem = GNUNET_YES; |
4882 | } | 4986 | } |
4883 | GNUNET_free (rpos); | 4987 | GNUNET_free (rpos); |
4884 | } | 4988 | } |
@@ -4965,6 +5069,7 @@ handle_ping(void *cls, const struct GNUNET_MessageHeader *message, | |||
4965 | plugin->env.my_identity, | 5069 | plugin->env.my_identity, |
4966 | sizeof (struct GNUNET_PeerIdentity))) | 5070 | sizeof (struct GNUNET_PeerIdentity))) |
4967 | { | 5071 | { |
5072 | #if DEBUG_TRANSPORT | ||
4968 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 5073 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
4969 | _("Received `%s' message from `%s' destined for `%s' which is not me!\n"), | 5074 | _("Received `%s' message from `%s' destined for `%s' which is not me!\n"), |
4970 | "PING", | 5075 | "PING", |
@@ -4974,6 +5079,7 @@ handle_ping(void *cls, const struct GNUNET_MessageHeader *message, | |||
4974 | sender_address_len) | 5079 | sender_address_len) |
4975 | : "<inbound>", | 5080 | : "<inbound>", |
4976 | GNUNET_i2s (&ping->target)); | 5081 | GNUNET_i2s (&ping->target)); |
5082 | #endif | ||
4977 | return GNUNET_SYSERR; | 5083 | return GNUNET_SYSERR; |
4978 | } | 5084 | } |
4979 | #if DEBUG_PING_PONG | 5085 | #if DEBUG_PING_PONG |
@@ -5359,11 +5465,13 @@ plugin_env_receive (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
5359 | ret = GNUNET_BANDWIDTH_tracker_get_delay (&n->in_tracker, 0); | 5465 | ret = GNUNET_BANDWIDTH_tracker_get_delay (&n->in_tracker, 0); |
5360 | if (ret.rel_value > 0) | 5466 | if (ret.rel_value > 0) |
5361 | { | 5467 | { |
5468 | #if DEBUG_TRANSPORT | ||
5362 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 5469 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
5363 | "Throttling read (%llu bytes excess at %u b/s), waiting %llums before reading more.\n", | 5470 | "Throttling read (%llu bytes excess at %u b/s), waiting %llums before reading more.\n", |
5364 | (unsigned long long) n->in_tracker.consumption_since_last_update__, | 5471 | (unsigned long long) n->in_tracker.consumption_since_last_update__, |
5365 | (unsigned int) n->in_tracker.available_bytes_per_s__, | 5472 | (unsigned int) n->in_tracker.available_bytes_per_s__, |
5366 | (unsigned long long) ret.rel_value); | 5473 | (unsigned long long) ret.rel_value); |
5474 | #endif | ||
5367 | GNUNET_STATISTICS_update (stats, | 5475 | GNUNET_STATISTICS_update (stats, |
5368 | gettext_noop ("# ms throttling suggested"), | 5476 | gettext_noop ("# ms throttling suggested"), |
5369 | (int64_t) ret.rel_value, | 5477 | (int64_t) ret.rel_value, |
@@ -5580,13 +5688,13 @@ handle_send (void *cls, | |||
5580 | obm = (const struct OutboundMessage *) message; | 5688 | obm = (const struct OutboundMessage *) message; |
5581 | obmm = (const struct GNUNET_MessageHeader *) &obm[1]; | 5689 | obmm = (const struct GNUNET_MessageHeader *) &obm[1]; |
5582 | msize = size - sizeof (struct OutboundMessage); | 5690 | msize = size - sizeof (struct OutboundMessage); |
5583 | 5691 | #if DEBUG_TRANSPORT | |
5584 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 5692 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
5585 | "Received `%s' request from client with target `%4s' and message of type %u and size %u\n", | 5693 | "Received `%s' request from client with target `%4s' and message of type %u and size %u\n", |
5586 | "SEND", GNUNET_i2s (&obm->peer), | 5694 | "SEND", GNUNET_i2s (&obm->peer), |
5587 | ntohs (obmm->type), | 5695 | ntohs (obmm->type), |
5588 | msize); | 5696 | msize); |
5589 | 5697 | #endif | |
5590 | tcmc = GNUNET_malloc (sizeof (struct TransmitClientMessageContext) + msize); | 5698 | tcmc = GNUNET_malloc (sizeof (struct TransmitClientMessageContext) + msize); |
5591 | tcmc->client = client; | 5699 | tcmc->client = client; |
5592 | tcmc->priority = ntohl (obm->priority); | 5700 | tcmc->priority = ntohl (obm->priority); |
@@ -5620,12 +5728,17 @@ handle_request_connect (void *cls, | |||
5620 | gettext_noop ("# REQUEST CONNECT messages received"), | 5728 | gettext_noop ("# REQUEST CONNECT messages received"), |
5621 | 1, | 5729 | 1, |
5622 | GNUNET_NO); | 5730 | GNUNET_NO); |
5623 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Received a request connect message for peer %s\n", GNUNET_i2s(&trcm->peer)); | 5731 | #if DEBUG_TRANSPORT |
5732 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | ||
5733 | "Received a request connect message for peer `%s'\n", | ||
5734 | GNUNET_i2s(&trcm->peer)); | ||
5735 | #endif | ||
5624 | setup_peer_check_blacklist (&trcm->peer, GNUNET_YES, | 5736 | setup_peer_check_blacklist (&trcm->peer, GNUNET_YES, |
5625 | NULL, NULL); | 5737 | NULL, NULL); |
5626 | GNUNET_SERVER_receive_done (client, GNUNET_OK); | 5738 | GNUNET_SERVER_receive_done (client, GNUNET_OK); |
5627 | } | 5739 | } |
5628 | 5740 | ||
5741 | |||
5629 | /** | 5742 | /** |
5630 | * Handle SET_QUOTA-message. | 5743 | * Handle SET_QUOTA-message. |
5631 | * | 5744 | * |
@@ -5668,9 +5781,11 @@ handle_set_quota (void *cls, | |||
5668 | qsm->quota); | 5781 | qsm->quota); |
5669 | if (0 == ntohl (qsm->quota.value__)) | 5782 | if (0 == ntohl (qsm->quota.value__)) |
5670 | { | 5783 | { |
5784 | #if DEBUG_TRANSPORT | ||
5671 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 5785 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
5672 | "Disconnecting peer `%4s', %s\n", GNUNET_i2s(&n->id), | 5786 | "Disconnecting peer `%4s', %s\n", GNUNET_i2s(&n->id), |
5673 | "SET_QUOTA"); | 5787 | "SET_QUOTA"); |
5788 | #endif | ||
5674 | disconnect_neighbour (n, GNUNET_NO); | 5789 | disconnect_neighbour (n, GNUNET_NO); |
5675 | } | 5790 | } |
5676 | GNUNET_SERVER_receive_done (client, GNUNET_OK); | 5791 | GNUNET_SERVER_receive_done (client, GNUNET_OK); |
@@ -5929,9 +6044,11 @@ shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
5929 | 6044 | ||
5930 | while (neighbours != NULL) | 6045 | while (neighbours != NULL) |
5931 | { | 6046 | { |
6047 | #if DEBUG_TRANSPORT | ||
5932 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 6048 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
5933 | "Disconnecting peer `%4s', %s\n", GNUNET_i2s(&neighbours->id), | 6049 | "Disconnecting peer `%4s', %s\n", GNUNET_i2s(&neighbours->id), |
5934 | "SHUTDOWN_TASK"); | 6050 | "SHUTDOWN_TASK"); |
6051 | #endif | ||
5935 | disconnect_neighbour (neighbours, GNUNET_NO); | 6052 | disconnect_neighbour (neighbours, GNUNET_NO); |
5936 | } | 6053 | } |
5937 | #if DEBUG_TRANSPORT | 6054 | #if DEBUG_TRANSPORT |
diff --git a/src/transport/plugin_transport_tcp.c b/src/transport/plugin_transport_tcp.c index 9dc67dcdf..fdf6a1882 100644 --- a/src/transport/plugin_transport_tcp.c +++ b/src/transport/plugin_transport_tcp.c | |||
@@ -38,7 +38,7 @@ | |||
38 | #include "gnunet_transport_plugin.h" | 38 | #include "gnunet_transport_plugin.h" |
39 | #include "transport.h" | 39 | #include "transport.h" |
40 | 40 | ||
41 | #define DEBUG_TCP GNUNET_NO | 41 | #define DEBUG_TCP GNUNET_YES |
42 | 42 | ||
43 | #define DEBUG_TCP_NAT GNUNET_NO | 43 | #define DEBUG_TCP_NAT GNUNET_NO |
44 | 44 | ||
@@ -1547,6 +1547,10 @@ tcp_plugin_disconnect (void *cls, | |||
1547 | pm->transmit_cont_cls = NULL; | 1547 | pm->transmit_cont_cls = NULL; |
1548 | pm = pm->next; | 1548 | pm = pm->next; |
1549 | } | 1549 | } |
1550 | GNUNET_STATISTICS_update (session->plugin->env->stats, | ||
1551 | gettext_noop ("# transport-service disconnect requests for TCP"), | ||
1552 | 1, | ||
1553 | GNUNET_NO); | ||
1550 | disconnect_session (session); | 1554 | disconnect_session (session); |
1551 | } | 1555 | } |
1552 | } | 1556 | } |
@@ -2127,6 +2131,10 @@ disconnect_notify (void *cls, | |||
2127 | session->connect_addr, | 2131 | session->connect_addr, |
2128 | session->connect_alen) : "*"); | 2132 | session->connect_alen) : "*"); |
2129 | #endif | 2133 | #endif |
2134 | GNUNET_STATISTICS_update (session->plugin->env->stats, | ||
2135 | gettext_noop ("# network-level TCP disconnect events"), | ||
2136 | 1, | ||
2137 | GNUNET_NO); | ||
2130 | disconnect_session (session); | 2138 | disconnect_session (session); |
2131 | } | 2139 | } |
2132 | 2140 | ||
diff --git a/src/transport/transport.h b/src/transport/transport.h index c06e42eaa..343679b2e 100644 --- a/src/transport/transport.h +++ b/src/transport/transport.h | |||
@@ -37,7 +37,9 @@ | |||
37 | #define ATS_MAX_ITERATIONS INT_MAX | 37 | #define ATS_MAX_ITERATIONS INT_MAX |
38 | 38 | ||
39 | #define DEBUG_TRANSPORT GNUNET_NO | 39 | #define DEBUG_TRANSPORT GNUNET_NO |
40 | |||
40 | #define DEBUG_TRANSPORT_TIMEOUT GNUNET_NO | 41 | #define DEBUG_TRANSPORT_TIMEOUT GNUNET_NO |
42 | |||
41 | #define DEBUG_TRANSPORT_DISCONNECT GNUNET_NO | 43 | #define DEBUG_TRANSPORT_DISCONNECT GNUNET_NO |
42 | 44 | ||
43 | /** | 45 | /** |