aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2010-11-22 22:53:51 +0000
committerChristian Grothoff <christian@grothoff.org>2010-11-22 22:53:51 +0000
commitae599d28651deb54edf98dd610883e4b4a0b7c7b (patch)
tree3882f4ac914dad3ed1314ec26622af51c7d78323
parent152b43342e4b842a4bff4906687b40b326403766 (diff)
downloadgnunet-ae599d28651deb54edf98dd610883e4b4a0b7c7b.tar.gz
gnunet-ae599d28651deb54edf98dd610883e4b4a0b7c7b.zip
initialize uninit
-rw-r--r--src/core/gnunet-service-core.c29
1 files changed, 22 insertions, 7 deletions
diff --git a/src/core/gnunet-service-core.c b/src/core/gnunet-service-core.c
index 1a43b46c3..a13f3a213 100644
--- a/src/core/gnunet-service-core.c
+++ b/src/core/gnunet-service-core.c
@@ -860,6 +860,21 @@ derive_pong_iv (struct GNUNET_CRYPTO_AesInitializationVector *iv,
860 860
861 861
862/** 862/**
863 * At what time should the connection to the given neighbour
864 * time out (given no further activity?)
865 *
866 * @param n neighbour in question
867 * @return absolute timeout
868 */
869static struct GNUNET_TIME_Absolute
870get_neighbour_timeout (struct Neighbour *n)
871{
872 return GNUNET_TIME_absolute_add (n->last_activity,
873 GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT);
874}
875
876
877/**
863 * A preference value for a neighbour was update. Update 878 * A preference value for a neighbour was update. Update
864 * the preference sum accordingly. 879 * the preference sum accordingly.
865 * 880 *
@@ -991,8 +1006,7 @@ handle_peer_status_change (struct Neighbour *n)
991 psnm.ats_count = htonl (0); 1006 psnm.ats_count = htonl (0);
992 psnm.ats.type = htonl (0); 1007 psnm.ats.type = htonl (0);
993 psnm.ats.value = htonl (0); 1008 psnm.ats.value = htonl (0);
994 psnm.timeout = GNUNET_TIME_absolute_hton (GNUNET_TIME_absolute_add (n->last_activity, 1009 psnm.timeout = GNUNET_TIME_absolute_hton (get_neighbour_timeout (n));
995 GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT));
996 psnm.bandwidth_in = n->bw_in; 1010 psnm.bandwidth_in = n->bw_in;
997 psnm.bandwidth_out = n->bw_out; 1011 psnm.bandwidth_out = n->bw_out;
998 psnm.peer = n->peer; 1012 psnm.peer = n->peer;
@@ -1663,8 +1677,7 @@ send_keep_alive (void *cls,
1663 ((void *) &pm->target - (void *) pm)); 1677 ((void *) &pm->target - (void *) pm));
1664 process_encrypted_neighbour_queue (n); 1678 process_encrypted_neighbour_queue (n);
1665 /* reschedule PING job */ 1679 /* reschedule PING job */
1666 left = GNUNET_TIME_absolute_get_remaining (GNUNET_TIME_absolute_add (n->last_activity, 1680 left = GNUNET_TIME_absolute_get_remaining (get_neighbour_timeout (n));
1667 GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT));
1668 retry = GNUNET_TIME_relative_max (GNUNET_TIME_relative_divide (left, 2), 1681 retry = GNUNET_TIME_relative_max (GNUNET_TIME_relative_divide (left, 2),
1669 MIN_PING_FREQUENCY); 1682 MIN_PING_FREQUENCY);
1670 n->keep_alive_task 1683 n->keep_alive_task
@@ -1710,8 +1723,7 @@ consider_free_neighbour (struct Neighbour *n)
1710 (GNUNET_YES == n->is_connected) ) 1723 (GNUNET_YES == n->is_connected) )
1711 return; /* no chance */ 1724 return; /* no chance */
1712 1725
1713 left = GNUNET_TIME_absolute_get_remaining (GNUNET_TIME_absolute_add (n->last_activity, 1726 left = GNUNET_TIME_absolute_get_remaining (get_neighbour_timeout (n));
1714 GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT));
1715 if (left.rel_value > 0) 1727 if (left.rel_value > 0)
1716 { 1728 {
1717 if (n->dead_clean_task != GNUNET_SCHEDULER_NO_TASK) 1729 if (n->dead_clean_task != GNUNET_SCHEDULER_NO_TASK)
@@ -3382,7 +3394,10 @@ handle_pong (struct Neighbour *n,
3382 } 3394 }
3383 cnm.header.size = htons (sizeof (struct ConnectNotifyMessage)); 3395 cnm.header.size = htons (sizeof (struct ConnectNotifyMessage));
3384 cnm.header.type = htons (GNUNET_MESSAGE_TYPE_CORE_NOTIFY_CONNECT); 3396 cnm.header.type = htons (GNUNET_MESSAGE_TYPE_CORE_NOTIFY_CONNECT);
3397 cnm.ats_count = htonl (0);
3385 cnm.peer = n->peer; 3398 cnm.peer = n->peer;
3399 cnm.ats.type = htonl (0);
3400 cnm.ats.value = htonl (0);
3386 send_to_all_clients (&cnm.header, GNUNET_NO, GNUNET_CORE_OPTION_SEND_CONNECT); 3401 send_to_all_clients (&cnm.header, GNUNET_NO, GNUNET_CORE_OPTION_SEND_CONNECT);
3387 process_encrypted_neighbour_queue (n); 3402 process_encrypted_neighbour_queue (n);
3388 /* fall-through! */ 3403 /* fall-through! */
@@ -4047,7 +4062,7 @@ neighbour_quota_update (void *cls,
4047 else 4062 else
4048 q_in = GNUNET_BANDWIDTH_value_init (need_per_peer + (uint32_t) share); 4063 q_in = GNUNET_BANDWIDTH_value_init (need_per_peer + (uint32_t) share);
4049 /* check if we want to disconnect for good due to inactivity */ 4064 /* check if we want to disconnect for good due to inactivity */
4050 if ( (GNUNET_TIME_absolute_get_duration (n->last_activity).rel_value > GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT.rel_value) && 4065 if ( (GNUNET_TIME_absolute_get_duration (get_neighbour_timeout (n)).rel_value > 0) &&
4051 (GNUNET_TIME_absolute_get_duration (n->time_established).rel_value > GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT.rel_value) ) 4066 (GNUNET_TIME_absolute_get_duration (n->time_established).rel_value > GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT.rel_value) )
4052 { 4067 {
4053#if DEBUG_CORE 4068#if DEBUG_CORE