1
0
Fork 0
mirror of https://github.com/transmission/transmission synced 2024-12-25 09:13:06 +00:00

fix overflow error that caused timers with intervals larger than 35 minutes to be lost... which is nastier than it sounds, since that's shorter than many tracker announce intervals.

This commit is contained in:
Charles Kerr 2007-10-18 18:32:58 +00:00
parent 6cef3fd9f9
commit 212470560e
5 changed files with 19 additions and 11 deletions

View file

@ -315,16 +315,18 @@ onTrackerFreeNow( void * vt )
tr_free( t->trackerID );
tr_free( t->lastRequest );
/* addresses... */
for( i=0; i<t->addressCount; ++i )
tr_trackerInfoClear( &t->addresses[i] );
tr_free( t->addresses );
tr_free( t->tierFronts );
/* redirect... */
if( t->redirect ) {
tr_trackerInfoClear( t->redirect );
tr_free( t->redirect );
}
tr_free( t->addresses );
tr_free( t->tierFronts );
tr_free( t );
}
@ -877,6 +879,7 @@ sendTrackerRequest( void * vt, const char * eventName )
uri );
/* kill any pending requests */
dbgmsg( t, "clearing announce timer" );
tr_timerFree( &t->reannounceTimer );
evcon = getConnection( t, address->address, address->port );
@ -908,7 +911,9 @@ static int
onReannounce( void * vt )
{
tr_tracker * t = vt;
dbgmsg( t, "onReannounce" );
sendTrackerRequest( t, "" );
dbgmsg( t, "onReannounce setting announceTimer to NULL" );
t->reannounceTimer = NULL;
return FALSE;
}
@ -917,7 +922,9 @@ static int
onRetry( void * vt )
{
tr_tracker * t = vt;
dbgmsg( t, "onRetry" );
sendTrackerRequest( t, t->lastRequest );
dbgmsg( t, "onRetry setting announceTimer to NULL" );
t->reannounceTimer = NULL;
return FALSE;
}

View file

@ -381,7 +381,7 @@ tr_timer*
tr_timerNew( struct tr_handle * handle,
timer_func func,
void * user_data,
int timeout_milliseconds )
uint64_t timeout_milliseconds )
{
tr_timer * timer = tr_new0( tr_timer, 1 );
timer->tv = timevalMsec( timeout_milliseconds );

View file

@ -12,7 +12,8 @@
#ifndef TR_EVENT_H
#include <stddef.h> /* for size_t */
#include <stddef.h> /* size_t */
#include <inttypes.h> /* uint64_t */
/**
**/
@ -61,7 +62,7 @@ typedef struct tr_timer tr_timer;
tr_timer* tr_timerNew( struct tr_handle * handle,
int func( void * user_data ),
void * user_data,
int timeout_milliseconds );
uint64_t timeout_milliseconds );
/**
* Frees a timer and sets the timer pointer to NULL.

View file

@ -397,10 +397,10 @@ timevalSec ( int seconds )
}
struct timeval
timevalMsec ( int milliseconds )
timevalMsec( uint64_t milliseconds )
{
struct timeval ret;
const unsigned long microseconds = milliseconds * 1000;
const uint64_t microseconds = milliseconds * 1000;
ret.tv_sec = microseconds / 1000000;
ret.tv_usec = microseconds % 1000000;
return ret;

View file

@ -80,11 +80,11 @@ int tr_concat( char ** buf, int * used, int * max,
/* creates a filename from a series of elements using the
correct separator for filenames. */
void tr_buildPath ( char* buf, size_t buflen,
const char * first_element, ... );
void tr_buildPath( char* buf, size_t buflen,
const char * first_element, ... );
struct timeval timevalSec ( int seconds );
struct timeval timevalMsec ( int milliseconds );
struct timeval timevalSec( int seconds );
struct timeval timevalMsec( uint64_t milliseconds );
int tr_ioErrorFromErrno( void );