aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorNathan S. Evans <evans@in.tum.de>2010-02-04 15:53:47 +0000
committerNathan S. Evans <evans@in.tum.de>2010-02-04 15:53:47 +0000
commitfdf2dcaeaff0cb9b043e1d0ec644e5b6719dce04 (patch)
treeb67e0340e50752013bb455a9fe68ee8478e7189b /src
parenteaeb9cc73fcaedf5f4801c996bb54499aea5afcf (diff)
downloadgnunet-fdf2dcaeaff0cb9b043e1d0ec644e5b6719dce04.tar.gz
gnunet-fdf2dcaeaff0cb9b043e1d0ec644e5b6719dce04.zip
cheapest address calculation fix
Diffstat (limited to 'src')
-rw-r--r--src/transport/gnunet-service-transport.c39
1 files changed, 26 insertions, 13 deletions
diff --git a/src/transport/gnunet-service-transport.c b/src/transport/gnunet-service-transport.c
index e0802c758..9d098b6da 100644
--- a/src/transport/gnunet-service-transport.c
+++ b/src/transport/gnunet-service-transport.c
@@ -1152,12 +1152,12 @@ find_ready_address(struct NeighborList *neighbor)
1152 { 1152 {
1153 if ((addresses->connected == GNUNET_YES) && 1153 if ((addresses->connected == GNUNET_YES) &&
1154 (addresses->transmit_ready == GNUNET_YES) && 1154 (addresses->transmit_ready == GNUNET_YES) &&
1155 ((addresses->latency.value < min_latency.value) || (best_address == NULL))) 1155 ((best_address == NULL) || (addresses->latency.value < best_address->latency.value)))
1156 { 1156 {
1157#if DEBUG_TRANSPORT 1157#if DEBUG_TRANSPORT
1158 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1158 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1159 "Found address with latency %llu, setting as best found yet!\n", 1159 "Found address with latency %llu (previous best was %llu), setting as best found yet!\n",
1160 addresses->latency.value); 1160 addresses->latency.value, best_address == NULL ? min_latency.value : best_address->latency.value);
1161#endif 1161#endif
1162 best_address = addresses; 1162 best_address = addresses;
1163 } 1163 }
@@ -1746,8 +1746,8 @@ handle_pong (void *cls, const struct GNUNET_MessageHeader *message,
1746 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1746 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1747 "Confirmed validity of address, peer `%4s' has address `%s'.\n", 1747 "Confirmed validity of address, peer `%4s' has address `%s'.\n",
1748 GNUNET_i2s (peer), 1748 GNUNET_i2s (peer),
1749 GNUNET_a2s ((const struct sockaddr *) sender_address, 1749 GNUNET_a2s ((const struct sockaddr *) va->peer_address->addr,
1750 sender_address_len)); 1750 va->peer_address->addrlen));
1751#endif 1751#endif
1752 GNUNET_log (GNUNET_ERROR_TYPE_INFO | GNUNET_ERROR_TYPE_BULK, 1752 GNUNET_log (GNUNET_ERROR_TYPE_INFO | GNUNET_ERROR_TYPE_BULK,
1753 _ 1753 _
@@ -1759,13 +1759,13 @@ handle_pong (void *cls, const struct GNUNET_MessageHeader *message,
1759 GNUNET_TIME_relative_to_absolute (HELLO_ADDRESS_EXPIRATION); 1759 GNUNET_TIME_relative_to_absolute (HELLO_ADDRESS_EXPIRATION);
1760 matched = GNUNET_YES; 1760 matched = GNUNET_YES;
1761 va->peer_address->connected = GNUNET_YES; 1761 va->peer_address->connected = GNUNET_YES;
1762 va->peer_address->latency = GNUNET_TIME_absolute_get_difference(va->peer_address->validation->send_time, GNUNET_TIME_absolute_get()); 1762 va->peer_address->latency = GNUNET_TIME_absolute_get_difference(va->send_time, GNUNET_TIME_absolute_get());
1763#if DEBUG_TRANSPORT 1763#if DEBUG_TRANSPORT
1764 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1764 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1765 "Confirmed validity of address, peer `%4s' has address `%s', latency of %llu\n", 1765 "Confirmed validity of address, peer `%4s' has address `%s', latency of %llu\n",
1766 GNUNET_i2s (peer), 1766 GNUNET_i2s (peer),
1767 GNUNET_a2s ((const struct sockaddr *) sender_address, 1767 GNUNET_a2s ((const struct sockaddr *) va->peer_address->addr,
1768 sender_address_len), (unsigned long long)va->peer_address->latency.value); 1768 va->peer_address->addrlen), (unsigned long long)va->peer_address->latency.value);
1769#endif 1769#endif
1770 va->peer_address->transmit_ready = GNUNET_YES; 1770 va->peer_address->transmit_ready = GNUNET_YES;
1771 va->peer_address->expires = GNUNET_TIME_relative_to_absolute 1771 va->peer_address->expires = GNUNET_TIME_relative_to_absolute
@@ -2011,7 +2011,7 @@ run_validation (void *cls,
2011 memcpy(&ping->target, &id, sizeof(struct GNUNET_PeerIdentity)); 2011 memcpy(&ping->target, &id, sizeof(struct GNUNET_PeerIdentity));
2012 2012
2013#if DEBUG_TRANSPORT 2013#if DEBUG_TRANSPORT
2014 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "hello size is %d, ping size is %d, total size is %d", hello_size, sizeof(struct TransportPingMessage), tsize); 2014 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "hello size is %d, ping size is %d, total size is %d\n", hello_size, sizeof(struct TransportPingMessage), tsize);
2015#endif 2015#endif
2016 memcpy(message_buf, our_hello, hello_size); 2016 memcpy(message_buf, our_hello, hello_size);
2017 memcpy(&message_buf[hello_size], ping, sizeof(struct TransportPingMessage)); 2017 memcpy(&message_buf[hello_size], ping, sizeof(struct TransportPingMessage));
@@ -2192,8 +2192,6 @@ process_hello (struct TransportPlugin *plugin,
2192 "Notifying peerinfo about peer %s\n", 2192 "Notifying peerinfo about peer %s\n",
2193 GNUNET_i2s (&target)); 2193 GNUNET_i2s (&target));
2194#endif 2194#endif
2195 /* For some reason the line below causes something to hang up... maybe peerinfo isn't ready yet? */
2196 /*GNUNET_PEERINFO_add_peer (cfg, sched, &target, hello); */
2197 2195
2198 /* check if a HELLO for this peer is already on the validation list */ 2196 /* check if a HELLO for this peer is already on the validation list */
2199 e = pending_validations; 2197 e = pending_validations;
@@ -2507,11 +2505,16 @@ plugin_env_receive (void *cls, const struct GNUNET_PeerIdentity *peer,
2507 GNUNET_log (GNUNET_ERROR_TYPE_WARNING | 2505 GNUNET_log (GNUNET_ERROR_TYPE_WARNING |
2508 GNUNET_ERROR_TYPE_BULK, 2506 GNUNET_ERROR_TYPE_BULK,
2509 _ 2507 _
2510 ("Dropping incoming message due to repeated bandwidth quota violations.\n")); 2508 ("Dropping incoming message due to repeated bandwidth quota violations (total of %u).\n"), n->quota_violation_count);
2511 /* TODO: call stats */ 2509 /* TODO: call stats */
2512 GNUNET_assert ((service_context == NULL) || 2510 GNUNET_assert ((service_context == NULL) ||
2513 (NULL != service_context->neighbor)); 2511 (NULL != service_context->neighbor));
2514 return; 2512
2513 GNUNET_log (GNUNET_ERROR_TYPE_WARNING |
2514 GNUNET_ERROR_TYPE_BULK,
2515 _
2516 ("NOT Dropping incoming message due to repeated bandwidth quota violations (total of %u).\n"), n->quota_violation_count);
2517 /* return; */
2515 } 2518 }
2516 switch (ntohs (message->type)) 2519 switch (ntohs (message->type))
2517 { 2520 {
@@ -2524,9 +2527,19 @@ plugin_env_receive (void *cls, const struct GNUNET_PeerIdentity *peer,
2524 process_hello (plugin, message); 2527 process_hello (plugin, message);
2525 break; 2528 break;
2526 case GNUNET_MESSAGE_TYPE_TRANSPORT_PING: 2529 case GNUNET_MESSAGE_TYPE_TRANSPORT_PING:
2530#if DEBUG_TRANSPORT
2531 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2532 "Receiving `%s' message from `%4s'.\n", "PING",
2533 GNUNET_i2s (peer));
2534#endif
2527 handle_ping(plugin, message, peer, sender_address, sender_address_len); 2535 handle_ping(plugin, message, peer, sender_address, sender_address_len);
2528 break; 2536 break;
2529 case GNUNET_MESSAGE_TYPE_TRANSPORT_PONG: 2537 case GNUNET_MESSAGE_TYPE_TRANSPORT_PONG:
2538#if DEBUG_TRANSPORT
2539 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2540 "Receiving `%s' message from `%4s'.\n", "PONG",
2541 GNUNET_i2s (peer));
2542#endif
2530 handle_pong(plugin, message, peer, sender_address, sender_address_len); 2543 handle_pong(plugin, message, peer, sender_address, sender_address_len);
2531 break; 2544 break;
2532 default: 2545 default: