Changeset 2334


Ignore:
Timestamp:
Jul 13, 2007, 1:34:14 AM (15 years ago)
Author:
charles
Message:

second draft of a fix for the tracker communication bug reported by TMT

Location:
trunk/libtransmission
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/http.c

    r2328 r2334  
    644644{
    645645    struct buf * buf;
    646     int          ret;
    647 
    648     if( 0 == http->date )
    649     {
    650         http->date = tr_date();
    651     }
     646
     647    if( !http->date )
     648         http->date = tr_date();
    652649
    653650    if( 0 > http->sock || tr_date() > http->date + HTTP_TIMEOUT )
     
    659656    while( 0 < buf->used )
    660657    {
    661       ret = tr_netSend( http->sock, (uint8_t *) buf->buf, buf->used );
    662         if( ret & TR_NET_CLOSE )
    663         {
    664             return TR_NET_ERROR;
    665         }
    666         else if( ret & TR_NET_BLOCK )
    667         {
    668             return TR_NET_WAIT;
    669         }
     658        const int ret = tr_netSend( http->sock, buf->buf, buf->used );
     659        if( ret & TR_NET_CLOSE ) return TR_NET_ERROR;
     660        if( ret & TR_NET_BLOCK ) return TR_NET_WAIT;
    670661        buf->used = 0;
    671662        buf = &http->body;
  • trunk/libtransmission/net.c

    r2328 r2334  
    375375}
    376376
    377 int tr_netSend( int s, uint8_t * buf, int size )
    378 {
    379     int ret;
    380 
    381     ret = send( s, buf, size, 0 );
    382     if( ret < 0 )
    383     {
    384         if( errno == ENOTCONN || errno == EAGAIN || errno == EWOULDBLOCK )
    385         {
    386             ret = TR_NET_BLOCK;
    387         }
    388         else
    389         {
    390             ret = TR_NET_CLOSE;
    391         }
    392     }
    393 
    394     return ret;
     377int
     378tr_netSend( int s, const void * buf, int size )
     379{
     380    const int ret = send( s, buf, size, 0 );
     381    if( ret >= 0 )
     382        return ret;
     383
     384    if( errno == ENOTCONN || errno == EAGAIN || errno == EWOULDBLOCK )
     385        return TR_NET_BLOCK;
     386
     387    return TR_NET_CLOSE;
    395388}
    396389
  • trunk/libtransmission/net.h

    r1579 r2334  
    5555#define TR_NET_BLOCK 0x80000000
    5656#define TR_NET_CLOSE 0x40000000
    57 int  tr_netSend    ( int s, uint8_t * buf, int size );
     57int  tr_netSend    ( int s, const void * buf, int size );
    5858#define tr_netRecv( s, buf, size ) tr_netRecvFrom( (s), (buf), (size), NULL )
    5959int  tr_netRecvFrom( int s, uint8_t * buf, int size, struct sockaddr_in * );
  • trunk/libtransmission/torrent.c

    r2333 r2334  
    994994        if( tor->runStatus == TR_RUN_STOPPING_NET_WAIT )
    995995        {
     996            uint64_t date;
     997            int peerCount;
     998            uint8_t * peerCompact;
     999            tr_trackerPulse( tor->tracker, &peerCount, &peerCompact );
     1000
    9961001            /* have we finished telling the tracker that we're stopping? */
    997             const uint64_t date = tr_trackerLastResponseDate( tor->tracker );
     1002            date = tr_trackerLastResponseDate( tor->tracker );
    9981003            if( date > tor->stopDate )
    9991004            {
  • trunk/libtransmission/tracker.c

    r2330 r2334  
    312312    *peerCompact = NULL;
    313313   
    314     if( ( NULL == tc->http ) && shouldConnect( tc ) )
     314    if( !tc->http && shouldConnect( tc ) )
    315315    {
    316316        tc->completelyUnconnectable = FALSE;
     
    390390    }
    391391
    392     if( NULL != tc->http )
     392    if( tc->http )
    393393    {
    394394        switch( tr_httpPulse( tc->http, &data, &len ) )
Note: See TracChangeset for help on using the changeset viewer.