changeset 1109:4f33090b96bf

Fix handling of the timeout value
author Sebastien Decugis <sdecugis@freediameter.net>
date Mon, 13 May 2013 10:12:10 +0800
parents 7ee7b95701c9
children a731051d2e83
files extensions/rt_busypeers/rtbusy.c
diffstat 1 files changed, 5 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/extensions/rt_busypeers/rtbusy.c	Mon May 13 09:46:39 2013 +0800
+++ b/extensions/rt_busypeers/rtbusy.c	Mon May 13 10:12:10 2013 +0800
@@ -148,8 +148,11 @@
 	
 	/* If the message is a request, we only associate the timeout */
 	if (hdr->msg_flags & CMD_FLAG_REQUEST) {
-		struct timespec tm = { .tv_sec = rtbusy_conf.RelayTimeout/1000, .tv_nsec=1000000LL * (rtbusy_conf.RelayTimeout % 1000) };
-		CHECK_FCT( fd_msg_anscb_associate( *pmsg, NULL, NULL, rtbusy_expirecb, &tm ) );
+		struct timespec expire;
+		CHECK_SYS(  clock_gettime(CLOCK_REALTIME, &expire)  );
+		expire.tv_sec += rtbusy_conf.RelayTimeout/1000 + ((expire.tv_nsec + (1000000LL * (rtbusy_conf.RelayTimeout % 1000))) / 1000000000LL);
+		expire.tv_nsec = (expire.tv_nsec + (1000000LL * (rtbusy_conf.RelayTimeout % 1000))) % 1000000000LL;
+		CHECK_FCT( fd_msg_anscb_associate( *pmsg, NULL, NULL, rtbusy_expirecb, &expire ) );
 		return 0;
 	}
 	
"Welcome to our mercurial repository"