diff options
author | Christian Grothoff <christian@grothoff.org> | 2011-06-06 11:26:59 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2011-06-06 11:26:59 +0000 |
commit | 59e49f5bfd27f228c73dfbefbc010bbb3fd94774 (patch) | |
tree | 5a60b79cddbbcb6c984b42fa99ec0fe8fef5f67f /src/transport | |
parent | 8eb690e76dce9788acfc83ea0991f64c31145a01 (diff) | |
download | gnunet-59e49f5bfd27f228c73dfbefbc010bbb3fd94774.tar.gz gnunet-59e49f5bfd27f228c73dfbefbc010bbb3fd94774.zip |
indentation fixed, logging
Diffstat (limited to 'src/transport')
-rw-r--r-- | src/transport/gnunet-service-transport.c | 68 | ||||
-rw-r--r-- | src/transport/plugin_transport_tcp.c | 53 |
2 files changed, 63 insertions, 58 deletions
diff --git a/src/transport/gnunet-service-transport.c b/src/transport/gnunet-service-transport.c index 8ea86c9fd..b34c0305a 100644 --- a/src/transport/gnunet-service-transport.c +++ b/src/transport/gnunet-service-transport.c | |||
@@ -4003,7 +4003,7 @@ schedule_next_ping (struct ForeignAddressList *fal) | |||
4003 | */ | 4003 | */ |
4004 | static void | 4004 | static void |
4005 | handle_payload_message (const struct GNUNET_MessageHeader *message, | 4005 | handle_payload_message (const struct GNUNET_MessageHeader *message, |
4006 | struct NeighbourList *n) | 4006 | struct NeighbourList *n) |
4007 | { | 4007 | { |
4008 | struct InboundMessage *im; | 4008 | struct InboundMessage *im; |
4009 | struct TransportClient *cpos; | 4009 | struct TransportClient *cpos; |
@@ -4014,7 +4014,7 @@ handle_payload_message (const struct GNUNET_MessageHeader *message, | |||
4014 | { | 4014 | { |
4015 | #if DEBUG_TRANSPORT | 4015 | #if DEBUG_TRANSPORT |
4016 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 4016 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
4017 | "Received message of type %u and size %u from `%4s', but no pong yet!!\n", | 4017 | "Received message of type %u and size %u from `%4s', but no pong yet!\n", |
4018 | ntohs (message->type), | 4018 | ntohs (message->type), |
4019 | ntohs (message->size), | 4019 | ntohs (message->size), |
4020 | GNUNET_i2s (&n->id)); | 4020 | GNUNET_i2s (&n->id)); |
@@ -5347,11 +5347,11 @@ plugin_env_receive (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
5347 | uint16_t msize; | 5347 | uint16_t msize; |
5348 | struct NeighbourList *n; | 5348 | struct NeighbourList *n; |
5349 | struct GNUNET_TIME_Relative ret; | 5349 | struct GNUNET_TIME_Relative ret; |
5350 | if (is_blacklisted (peer, plugin)) | ||
5351 | return GNUNET_TIME_UNIT_FOREVER_REL; | ||
5352 | uint32_t distance; | 5350 | uint32_t distance; |
5353 | int c; | 5351 | int c; |
5354 | 5352 | ||
5353 | if (is_blacklisted (peer, plugin)) | ||
5354 | return GNUNET_TIME_UNIT_FOREVER_REL; | ||
5355 | n = find_neighbour (peer); | 5355 | n = find_neighbour (peer); |
5356 | if (n == NULL) | 5356 | if (n == NULL) |
5357 | n = setup_new_neighbour (peer, GNUNET_YES); | 5357 | n = setup_new_neighbour (peer, GNUNET_YES); |
@@ -5363,17 +5363,12 @@ plugin_env_receive (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
5363 | distance = 1; | 5363 | distance = 1; |
5364 | 5364 | ||
5365 | for (c=0; c<ats_count; c++) | 5365 | for (c=0; c<ats_count; c++) |
5366 | { | 5366 | if (ntohl(ats_data[c].type) == GNUNET_TRANSPORT_ATS_QUALITY_NET_DISTANCE) |
5367 | if (ntohl(ats_data[c].type) == GNUNET_TRANSPORT_ATS_QUALITY_NET_DISTANCE) | 5367 | distance = ntohl(ats_data[c].value); |
5368 | { | 5368 | |
5369 | distance = ntohl(ats_data[c].value); | ||
5370 | } | ||
5371 | } | ||
5372 | |||
5373 | /* notify ATS about incoming data */ | 5369 | /* notify ATS about incoming data */ |
5374 | //ats_notify_ats_data(peer, ats_data); | 5370 | //ats_notify_ats_data(peer, ats_data); |
5375 | 5371 | ||
5376 | |||
5377 | if (message != NULL) | 5372 | if (message != NULL) |
5378 | { | 5373 | { |
5379 | if ( (session != NULL) || | 5374 | if ( (session != NULL) || |
@@ -5385,17 +5380,14 @@ plugin_env_receive (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
5385 | sender_address_len); | 5380 | sender_address_len); |
5386 | if (peer_address != NULL) | 5381 | if (peer_address != NULL) |
5387 | { | 5382 | { |
5388 | 5383 | update_addr_ats(peer_address, ats_data, ats_count); | |
5389 | update_addr_ats(peer_address, ats_data, ats_count); | 5384 | update_addr_value(peer_address, distance, GNUNET_TRANSPORT_ATS_QUALITY_NET_DISTANCE); |
5390 | update_addr_value(peer_address, distance, GNUNET_TRANSPORT_ATS_QUALITY_NET_DISTANCE); | 5385 | |
5391 | 5386 | peer_address->distance = distance; | |
5392 | peer_address->distance = distance; | ||
5393 | if (GNUNET_YES == peer_address->validated) | 5387 | if (GNUNET_YES == peer_address->validated) |
5394 | mark_address_connected (peer_address); | 5388 | mark_address_connected (peer_address); |
5395 | peer_address->timeout | 5389 | peer_address->timeout |
5396 | = | 5390 | = GNUNET_TIME_relative_to_absolute (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT); |
5397 | GNUNET_TIME_relative_to_absolute | ||
5398 | (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT); | ||
5399 | schedule_next_ping (peer_address); | 5391 | schedule_next_ping (peer_address); |
5400 | } | 5392 | } |
5401 | /* update traffic received amount ... */ | 5393 | /* update traffic received amount ... */ |
@@ -5430,32 +5422,32 @@ plugin_env_receive (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
5430 | } | 5422 | } |
5431 | if ((ntohs(message->type) == GNUNET_MESSAGE_TYPE_TRANSPORT_ATS) && | 5423 | if ((ntohs(message->type) == GNUNET_MESSAGE_TYPE_TRANSPORT_ATS) && |
5432 | (ntohs(message->size) == (sizeof (struct GNUNET_MessageHeader) + sizeof (uint32_t)))) | 5424 | (ntohs(message->size) == (sizeof (struct GNUNET_MessageHeader) + sizeof (uint32_t)))) |
5433 | { | 5425 | { |
5434 | uint32_t value = ntohl(*((uint32_t *) &message[1])); | 5426 | uint32_t value = ntohl(*((uint32_t *) &message[1])); |
5435 | //GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "GNUNET_MESSAGE_TYPE_TRANSPORT_ATS: %i \n", value); | 5427 | //GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "GNUNET_MESSAGE_TYPE_TRANSPORT_ATS: %i \n", value); |
5436 | /* Force ressource and quality update */ | 5428 | /* Force ressource and quality update */ |
5437 | if (value == 4) | 5429 | if (value == 4) |
5438 | { | 5430 | { |
5439 | ats->stat.modified_resources = GNUNET_YES; | 5431 | ats->stat.modified_resources = GNUNET_YES; |
5440 | ats->stat.modified_quality = GNUNET_YES; | 5432 | ats->stat.modified_quality = GNUNET_YES; |
5441 | } | 5433 | } |
5442 | /* Force cost update */ | 5434 | /* Force cost update */ |
5443 | if (value == 3) | 5435 | if (value == 3) |
5444 | ats->stat.modified_resources = GNUNET_YES; | 5436 | ats->stat.modified_resources = GNUNET_YES; |
5445 | /* Force quality update */ | 5437 | /* Force quality update */ |
5446 | if (value == 2) | 5438 | if (value == 2) |
5447 | ats->stat.modified_quality = GNUNET_YES; | 5439 | ats->stat.modified_quality = GNUNET_YES; |
5448 | /* Force full rebuild */ | 5440 | /* Force full rebuild */ |
5449 | if (value == 1) | 5441 | if (value == 1) |
5450 | ats->stat.recreate_problem = GNUNET_YES; | 5442 | ats->stat.recreate_problem = GNUNET_YES; |
5451 | } | 5443 | } |
5452 | 5444 | ||
5453 | #if DEBUG_PING_PONG | 5445 | #if DEBUG_PING_PONG |
5454 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 5446 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
5455 | "Received message of type %u and size %u from `%4s', sending to all clients.\n", | 5447 | "Received message of type %u and size %u from `%4s', sending to all clients.\n", |
5456 | ntohs (message->type), | 5448 | ntohs (message->type), |
5457 | ntohs (message->size), | 5449 | ntohs (message->size), |
5458 | GNUNET_i2s (peer)); | 5450 | GNUNET_i2s (peer)); |
5459 | #endif | 5451 | #endif |
5460 | switch (ntohs (message->type)) | 5452 | switch (ntohs (message->type)) |
5461 | { | 5453 | { |
@@ -5482,9 +5474,9 @@ plugin_env_receive (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
5482 | ret = GNUNET_BANDWIDTH_tracker_get_delay (&n->in_tracker, 0); | 5474 | ret = GNUNET_BANDWIDTH_tracker_get_delay (&n->in_tracker, 0); |
5483 | if (ret.rel_value > 0) | 5475 | if (ret.rel_value > 0) |
5484 | { | 5476 | { |
5485 | #if DEBUG_TRANSPORT | 5477 | #if DEBUG_TRANSPORT || 1 |
5486 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 5478 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
5487 | "Throttling read (%llu bytes excess at %u b/s), waiting %llums before reading more.\n", | 5479 | "Throttling read (%llu bytes excess at %u b/s), waiting %llu ms before reading more.\n", |
5488 | (unsigned long long) n->in_tracker.consumption_since_last_update__, | 5480 | (unsigned long long) n->in_tracker.consumption_since_last_update__, |
5489 | (unsigned int) n->in_tracker.available_bytes_per_s__, | 5481 | (unsigned int) n->in_tracker.available_bytes_per_s__, |
5490 | (unsigned long long) ret.rel_value); | 5482 | (unsigned long long) ret.rel_value); |
diff --git a/src/transport/plugin_transport_tcp.c b/src/transport/plugin_transport_tcp.c index bbce0d199..8d1f90590 100644 --- a/src/transport/plugin_transport_tcp.c +++ b/src/transport/plugin_transport_tcp.c | |||
@@ -2101,10 +2101,21 @@ handle_tcp_data (void *cls, | |||
2101 | (GNUNET_YES == session->inbound) ? NULL : session->connect_addr, | 2101 | (GNUNET_YES == session->inbound) ? NULL : session->connect_addr, |
2102 | (GNUNET_YES == session->inbound) ? 0 : session->connect_alen); | 2102 | (GNUNET_YES == session->inbound) ? 0 : session->connect_alen); |
2103 | if (delay.rel_value == 0) | 2103 | if (delay.rel_value == 0) |
2104 | GNUNET_SERVER_receive_done (client, GNUNET_OK); | 2104 | { |
2105 | GNUNET_SERVER_receive_done (client, GNUNET_OK); | ||
2106 | } | ||
2105 | else | 2107 | else |
2106 | session->receive_delay_task = | 2108 | { |
2107 | GNUNET_SCHEDULER_add_delayed (delay, &delayed_done, session); | 2109 | #if DEBUG_TCP || 1 |
2110 | GNUNET_log_from (GNUNET_ERROR_TYPE_INFO, | ||
2111 | "tcp", | ||
2112 | "Throttling receiving from `%s' for %llu ms\n", | ||
2113 | GNUNET_i2s (&session->target), | ||
2114 | (unsigned long long) delay.rel_value); | ||
2115 | #endif | ||
2116 | session->receive_delay_task = | ||
2117 | GNUNET_SCHEDULER_add_delayed (delay, &delayed_done, session); | ||
2118 | } | ||
2108 | } | 2119 | } |
2109 | 2120 | ||
2110 | 2121 | ||
@@ -2926,18 +2937,20 @@ libgnunet_plugin_transport_tcp_init (void *cls) | |||
2926 | } | 2937 | } |
2927 | 2938 | ||
2928 | if ((bind_address != NULL) && (internal_address != NULL)) | 2939 | if ((bind_address != NULL) && (internal_address != NULL)) |
2929 | { | 2940 | { |
2930 | if (0 != strcmp(internal_address, bind_address )) | 2941 | if (0 != strcmp(internal_address, bind_address )) |
2931 | { | 2942 | { |
2932 | GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, | 2943 | GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, |
2933 | "tcp","Specific bind address `%s' and internal address `%s' must not differ, forcing internal address to bind address!\n", bind_address, internal_address); | 2944 | "tcp", |
2934 | GNUNET_free (internal_address); | 2945 | "Specific bind address `%s' and internal address `%s' must not differ, forcing internal address to bind address!\n", |
2935 | internal_address = bind_address; | 2946 | bind_address, internal_address); |
2936 | GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, | 2947 | GNUNET_free (internal_address); |
2937 | "tcp","New internal address `%s'\n", internal_address); | 2948 | internal_address = bind_address; |
2938 | } | 2949 | GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, |
2939 | } | 2950 | "tcp","New internal address `%s'\n", internal_address); |
2940 | 2951 | } | |
2952 | } | ||
2953 | |||
2941 | aport = 0; | 2954 | aport = 0; |
2942 | if ( (GNUNET_OK != | 2955 | if ( (GNUNET_OK != |
2943 | GNUNET_CONFIGURATION_get_value_number (env->cfg, | 2956 | GNUNET_CONFIGURATION_get_value_number (env->cfg, |
@@ -2963,13 +2976,13 @@ libgnunet_plugin_transport_tcp_init (void *cls) | |||
2963 | 2976 | ||
2964 | use_localaddresses = GNUNET_NO; | 2977 | use_localaddresses = GNUNET_NO; |
2965 | if (GNUNET_CONFIGURATION_have_value (env->cfg, | 2978 | if (GNUNET_CONFIGURATION_have_value (env->cfg, |
2966 | "transport-tcp", "USE_LOCALADDR")) | 2979 | "transport-tcp", "USE_LOCALADDR")) |
2967 | { | 2980 | { |
2968 | use_localaddresses = GNUNET_CONFIGURATION_get_value_yesno (env->cfg, | 2981 | use_localaddresses = GNUNET_CONFIGURATION_get_value_yesno (env->cfg, |
2969 | "transport-tcp", | 2982 | "transport-tcp", |
2970 | "USE_LOCALADDR"); | 2983 | "USE_LOCALADDR"); |
2971 | } | 2984 | } |
2972 | 2985 | ||
2973 | if (aport == 0) | 2986 | if (aport == 0) |
2974 | aport = bport; | 2987 | aport = bport; |
2975 | if (bport == 0) | 2988 | if (bport == 0) |