diff options
Diffstat (limited to 'src/transport/gnunet-service-transport.c')
-rw-r--r-- | src/transport/gnunet-service-transport.c | 105 |
1 files changed, 69 insertions, 36 deletions
diff --git a/src/transport/gnunet-service-transport.c b/src/transport/gnunet-service-transport.c index 44d2ff726..7d3691696 100644 --- a/src/transport/gnunet-service-transport.c +++ b/src/transport/gnunet-service-transport.c | |||
@@ -58,9 +58,12 @@ | |||
58 | * messages, so the number should be chosen rather generously. | 58 | * messages, so the number should be chosen rather generously. |
59 | * | 59 | * |
60 | * The expectation here is that most of the time the queue is large | 60 | * The expectation here is that most of the time the queue is large |
61 | * enough so that a drop is virtually never required. | 61 | * enough so that a drop is virtually never required. Note that |
62 | * this value must be about as large as 'TOTAL_MSGS' in the | ||
63 | * 'test_transport_api_reliability.c', otherwise that testcase may | ||
64 | * fail. | ||
62 | */ | 65 | */ |
63 | #define MAX_PENDING 128 | 66 | #define MAX_PENDING (128 * 1024) |
64 | 67 | ||
65 | /** | 68 | /** |
66 | * Size of the per-transport blacklist hash maps. | 69 | * Size of the per-transport blacklist hash maps. |
@@ -1225,6 +1228,32 @@ transmit_to_client_callback (void *cls, size_t size, void *buf) | |||
1225 | 1228 | ||
1226 | 1229 | ||
1227 | /** | 1230 | /** |
1231 | * Convert an address to a string. | ||
1232 | * | ||
1233 | * @param plugin name of the plugin responsible for the address | ||
1234 | * @param addr binary address | ||
1235 | * @param addr_len number of bytes in addr | ||
1236 | * @return NULL on error, otherwise address string | ||
1237 | */ | ||
1238 | static const char* | ||
1239 | a2s (const char *plugin, | ||
1240 | const void *addr, | ||
1241 | uint16_t addr_len) | ||
1242 | { | ||
1243 | struct TransportPlugin *p; | ||
1244 | |||
1245 | if (plugin == NULL) | ||
1246 | return NULL; | ||
1247 | p = find_transport (plugin); | ||
1248 | if (p == NULL) | ||
1249 | return NULL; | ||
1250 | return p->api->address_to_string (p->api->cls, | ||
1251 | addr, | ||
1252 | addr_len); | ||
1253 | } | ||
1254 | |||
1255 | |||
1256 | /** | ||
1228 | * Mark the given FAL entry as 'connected' (and hence preferred for | 1257 | * Mark the given FAL entry as 'connected' (and hence preferred for |
1229 | * sending); also mark all others for the same peer as 'not connected' | 1258 | * sending); also mark all others for the same peer as 'not connected' |
1230 | * (since only one can be preferred). | 1259 | * (since only one can be preferred). |
@@ -1246,9 +1275,20 @@ mark_address_connected (struct ForeignAddressList *fal) | |||
1246 | { | 1275 | { |
1247 | if (GNUNET_YES == pos->connected) | 1276 | if (GNUNET_YES == pos->connected) |
1248 | { | 1277 | { |
1278 | #if DEBUG_TRANSPORT | ||
1279 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
1280 | "Marking address `%s' as no longer connected (due to connect on other address)\n", | ||
1281 | a2s (pos->ready_list->plugin->short_name, | ||
1282 | pos->addr, | ||
1283 | pos->addrlen)); | ||
1284 | #endif | ||
1249 | GNUNET_break (cnt == GNUNET_YES); | 1285 | GNUNET_break (cnt == GNUNET_YES); |
1250 | cnt = GNUNET_NO; | 1286 | cnt = GNUNET_NO; |
1251 | pos->connected = GNUNET_NO; | 1287 | pos->connected = GNUNET_NO; |
1288 | GNUNET_STATISTICS_update (stats, | ||
1289 | gettext_noop ("# connected addresses"), | ||
1290 | -1, | ||
1291 | GNUNET_NO); | ||
1252 | } | 1292 | } |
1253 | pos = pos->next; | 1293 | pos = pos->next; |
1254 | } | 1294 | } |
@@ -1284,9 +1324,15 @@ transmit_to_client (struct TransportClient *client, | |||
1284 | { | 1324 | { |
1285 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 1325 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
1286 | _ | 1326 | _ |
1287 | ("Dropping message, have %u messages pending (%u is the soft limit)\n"), | 1327 | ("Dropping message of type %u and size %u, have %u messages pending (%u is the soft limit)\n"), |
1288 | client->message_count, MAX_PENDING); | 1328 | ntohs (msg->type), |
1289 | /* TODO: call to statistics... */ | 1329 | ntohs (msg->size), |
1330 | client->message_count, | ||
1331 | MAX_PENDING); | ||
1332 | GNUNET_STATISTICS_update (stats, | ||
1333 | gettext_noop ("# messages dropped due to slow client"), | ||
1334 | 1, | ||
1335 | GNUNET_NO); | ||
1290 | return; | 1336 | return; |
1291 | } | 1337 | } |
1292 | msize = ntohs (msg->size); | 1338 | msize = ntohs (msg->size); |
@@ -1390,6 +1436,13 @@ transmit_send_continuation (void *cls, | |||
1390 | { | 1436 | { |
1391 | if (mq->specific_address->connected != GNUNET_NO) | 1437 | if (mq->specific_address->connected != GNUNET_NO) |
1392 | { | 1438 | { |
1439 | #if DEBUG_TRANSPORT | ||
1440 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
1441 | "Marking address `%s' as no longer connected (due to transmission problem)\n", | ||
1442 | a2s (mq->specific_address->ready_list->plugin->short_name, | ||
1443 | mq->specific_address->addr, | ||
1444 | mq->specific_address->addrlen)); | ||
1445 | #endif | ||
1393 | GNUNET_STATISTICS_update (stats, | 1446 | GNUNET_STATISTICS_update (stats, |
1394 | gettext_noop ("# connected addresses"), | 1447 | gettext_noop ("# connected addresses"), |
1395 | -1, | 1448 | -1, |
@@ -1408,32 +1461,6 @@ transmit_send_continuation (void *cls, | |||
1408 | 1461 | ||
1409 | 1462 | ||
1410 | /** | 1463 | /** |
1411 | * Convert an address to a string. | ||
1412 | * | ||
1413 | * @param plugin name of the plugin responsible for the address | ||
1414 | * @param addr binary address | ||
1415 | * @param addr_len number of bytes in addr | ||
1416 | * @return NULL on error, otherwise address string | ||
1417 | */ | ||
1418 | static const char* | ||
1419 | a2s (const char *plugin, | ||
1420 | const void *addr, | ||
1421 | uint16_t addr_len) | ||
1422 | { | ||
1423 | struct TransportPlugin *p; | ||
1424 | |||
1425 | if (plugin == NULL) | ||
1426 | return NULL; | ||
1427 | p = find_transport (plugin); | ||
1428 | if (p == NULL) | ||
1429 | return NULL; | ||
1430 | return p->api->address_to_string (p->api->cls, | ||
1431 | addr, | ||
1432 | addr_len); | ||
1433 | } | ||
1434 | |||
1435 | |||
1436 | /** | ||
1437 | * Find an address in any of the available transports for | 1464 | * Find an address in any of the available transports for |
1438 | * the given neighbour that would be good for message | 1465 | * the given neighbour that would be good for message |
1439 | * transmission. This is essentially the transport selection | 1466 | * transmission. This is essentially the transport selection |
@@ -1508,7 +1535,10 @@ find_ready_address(struct NeighbourList *neighbour) | |||
1508 | { | 1535 | { |
1509 | #if DEBUG_TRANSPORT | 1536 | #if DEBUG_TRANSPORT |
1510 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1537 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1511 | "Best address found has latency of %llu ms.\n", | 1538 | "Best address found (`%s') has latency of %llu ms.\n", |
1539 | a2s (best_address->ready_list->plugin->short_name, | ||
1540 | best_address->addr, | ||
1541 | best_address->addrlen), | ||
1512 | best_address->latency.value); | 1542 | best_address->latency.value); |
1513 | #endif | 1543 | #endif |
1514 | } | 1544 | } |
@@ -3228,8 +3258,9 @@ handle_payload_message (const struct GNUNET_MessageHeader *message, | |||
3228 | } | 3258 | } |
3229 | #if DEBUG_TRANSPORT | 3259 | #if DEBUG_TRANSPORT |
3230 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 3260 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
3231 | "Received message of type %u from `%4s', sending to all clients.\n", | 3261 | "Received message of type %u and size %u from `%4s', sending to all clients.\n", |
3232 | ntohs (message->type), | 3262 | ntohs (message->type), |
3263 | ntohs (message->size), | ||
3233 | GNUNET_i2s (&n->id)); | 3264 | GNUNET_i2s (&n->id)); |
3234 | #endif | 3265 | #endif |
3235 | if (GNUNET_YES == GNUNET_BANDWIDTH_tracker_consume (&n->in_tracker, | 3266 | if (GNUNET_YES == GNUNET_BANDWIDTH_tracker_consume (&n->in_tracker, |
@@ -3718,7 +3749,7 @@ check_hello_validated (void *cls, | |||
3718 | NULL); | 3749 | NULL); |
3719 | GNUNET_PEERINFO_add_peer (peerinfo, plain_hello); | 3750 | GNUNET_PEERINFO_add_peer (peerinfo, plain_hello); |
3720 | GNUNET_free (plain_hello); | 3751 | GNUNET_free (plain_hello); |
3721 | #if DEBUG_TRANSPORT || 1 | 3752 | #if DEBUG_TRANSPORT |
3722 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 3753 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
3723 | "PEERINFO had no `%s' message for peer `%4s', full validation needed.\n", | 3754 | "PEERINFO had no `%s' message for peer `%4s', full validation needed.\n", |
3724 | "HELLO", | 3755 | "HELLO", |
@@ -4248,8 +4279,10 @@ plugin_env_receive (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
4248 | } | 4279 | } |
4249 | #if DEBUG_PING_PONG | 4280 | #if DEBUG_PING_PONG |
4250 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 4281 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
4251 | "Received message of type %u from `%4s', sending to all clients.\n", | 4282 | "Received message of type %u and size %u from `%4s', sending to all clients.\n", |
4252 | ntohs (message->type), GNUNET_i2s (peer)); | 4283 | ntohs (message->type), |
4284 | ntohs (message->size), | ||
4285 | GNUNET_i2s (peer)); | ||
4253 | #endif | 4286 | #endif |
4254 | switch (ntohs (message->type)) | 4287 | switch (ntohs (message->type)) |
4255 | { | 4288 | { |