aboutsummaryrefslogtreecommitdiff
path: root/src/core/gnunet-service-core_kx.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2014-05-09 16:26:55 +0000
committerChristian Grothoff <christian@grothoff.org>2014-05-09 16:26:55 +0000
commitdb718fae66b0f4093730cac19b5d19d026ebf46e (patch)
tree2ee7adf83ebdd43a7e58b05c6ba126a58a0365ab /src/core/gnunet-service-core_kx.c
parent68ad058c614e4cf117fc898e678e4a1200a0e95d (diff)
downloadgnunet-db718fae66b0f4093730cac19b5d19d026ebf46e.tar.gz
gnunet-db718fae66b0f4093730cac19b5d19d026ebf46e.zip
only notify clients about significant (>5s) timeout changes
Diffstat (limited to 'src/core/gnunet-service-core_kx.c')
-rw-r--r--src/core/gnunet-service-core_kx.c17
1 files changed, 16 insertions, 1 deletions
diff --git a/src/core/gnunet-service-core_kx.c b/src/core/gnunet-service-core_kx.c
index 38f37f01f..4bf1b7925 100644
--- a/src/core/gnunet-service-core_kx.c
+++ b/src/core/gnunet-service-core_kx.c
@@ -290,6 +290,11 @@ struct GSC_KeyExchangeInfo
290 struct GNUNET_TIME_Absolute timeout; 290 struct GNUNET_TIME_Absolute timeout;
291 291
292 /** 292 /**
293 * What was the last timeout we informed our monitors about?
294 */
295 struct GNUNET_TIME_Absolute last_notify_timeout;
296
297 /**
293 * At what frequency are we currently re-trying SET_KEY messages? 298 * At what frequency are we currently re-trying SET_KEY messages?
294 */ 299 */
295 struct GNUNET_TIME_Relative set_key_retry_frequency; 300 struct GNUNET_TIME_Relative set_key_retry_frequency;
@@ -419,6 +424,7 @@ monitor_notify_all (struct GSC_KeyExchangeInfo *kx)
419 GNUNET_SERVER_notification_context_broadcast (nc, 424 GNUNET_SERVER_notification_context_broadcast (nc,
420 &msg.header, 425 &msg.header,
421 GNUNET_NO); 426 GNUNET_NO);
427 kx->last_notify_timeout = kx->timeout;
422} 428}
423 429
424 430
@@ -1086,10 +1092,19 @@ send_keep_alive (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
1086static void 1092static void
1087update_timeout (struct GSC_KeyExchangeInfo *kx) 1093update_timeout (struct GSC_KeyExchangeInfo *kx)
1088{ 1094{
1095 struct GNUNET_TIME_Relative delta;
1096
1089 kx->timeout = 1097 kx->timeout =
1090 GNUNET_TIME_relative_to_absolute 1098 GNUNET_TIME_relative_to_absolute
1091 (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT); 1099 (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT);
1092 monitor_notify_all (kx); 1100 delta = GNUNET_TIME_absolute_get_difference (kx->last_notify_timeout,
1101 kx->timeout);
1102 if (delta.rel_value_us > 5LL * 1000LL * 1000LL)
1103 {
1104 /* we only notify monitors about timeout changes if those
1105 are bigger than the threshold (5s) */
1106 monitor_notify_all (kx);
1107 }
1093 if (kx->keep_alive_task != GNUNET_SCHEDULER_NO_TASK) 1108 if (kx->keep_alive_task != GNUNET_SCHEDULER_NO_TASK)
1094 GNUNET_SCHEDULER_cancel (kx->keep_alive_task); 1109 GNUNET_SCHEDULER_cancel (kx->keep_alive_task);
1095 kx->keep_alive_task = 1110 kx->keep_alive_task =