(trunkn libT) #3192 "crash in most recent nightlies" -- fixed in trunk for 2.00

This commit is contained in:
Charles Kerr 2010-05-18 15:14:54 +00:00
parent c7bbd4dc20
commit fcc56ddcd5
1 changed files with 13 additions and 1 deletions

View File

@ -616,6 +616,18 @@ publishWarning( tr_tier * tier, const char * msg )
publishMessage( tier, msg, TR_TRACKER_WARNING );
}
static int
getSeedProbability( int seeds, int leechers )
{
if( !seeds )
return 0;
if( seeds>=0 && leechers>=0 )
return (int)((100.0*seeds)/(seeds+leechers));
return -1; /* unknown */
}
static int
publishNewPeers( tr_tier * tier, int seeds, int leechers,
const void * compact, int compactLen )
@ -623,7 +635,7 @@ publishNewPeers( tr_tier * tier, int seeds, int leechers,
tr_tracker_event e = emptyEvent;
e.messageType = TR_TRACKER_PEERS;
e.seedProbability = seeds+leechers ? (int)((100.0*seeds)/(seeds+leechers)) : -1;
e.seedProbability = getSeedProbability( seeds, leechers );
e.compact = compact;
e.compactLen = compactLen;