From 87d1f5ca34f66c0084385abd444907a5370217da Mon Sep 17 00:00:00 2001 From: Juliusz Chroboczek Date: Fri, 18 Feb 2011 00:24:04 +0000 Subject: [PATCH] Check for UTP timeouts every 50ms or so. Greg says that works for them. --- libtransmission/tr-utp.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/libtransmission/tr-utp.c b/libtransmission/tr-utp.c index 55fdb34ef..af557408a 100644 --- a/libtransmission/tr-utp.c +++ b/libtransmission/tr-utp.c @@ -34,6 +34,10 @@ THE SOFTWARE. #include "peer-mgr.h" #include "tr-utp.h" +/* Greg says 50ms works for them. */ + +#define UTP_INTERVAL_US 50000 + static struct event *utp_timer = NULL; static void @@ -82,7 +86,8 @@ static void timer_callback(int s UNUSED, short type UNUSED, void *closure UNUSED) { UTP_CheckTimeouts(); - tr_timerAdd(utp_timer, 1, tr_cryptoWeakRandInt(1000000)); + tr_timerAdd(utp_timer, 0, + UTP_INTERVAL_US / 2 + tr_cryptoWeakRandInt(UTP_INTERVAL_US)); } int @@ -95,7 +100,8 @@ tr_utpPacket(const unsigned char *buf, size_t buflen, if(utp_timer == NULL) return -1; evtimer_set(utp_timer, timer_callback, NULL); - tr_timerAdd(utp_timer, 1, tr_cryptoWeakRandInt(1000000)); + tr_timerAdd(utp_timer, 0, + UTP_INTERVAL_US / 2 + tr_cryptoWeakRandInt(UTP_INTERVAL_US)); } return UTP_IsIncomingUTP(incoming, send_to, ss,