Ignore:
Timestamp:
Jun 6, 2009, 4:19:34 PM (12 years ago)
Author:
charles
Message:

(trunk libT) #2151: possible fix for "Unusually high CPU usage in latest builds" issue

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/fdlimit.c

    r8575 r8636  
    600600                   tr_port     * port )
    601601{
    602     int                s = -1;
    603     unsigned int       len;
     602    int s;
     603    unsigned int len;
    604604    struct sockaddr_storage sock;
     605    tr_lockLock( gFd->lock );
    605606
    606607    assert( addr );
    607608    assert( port );
    608609
    609     tr_lockLock( gFd->lock );
    610     if( gFd->socketCount < getSocketMax( gFd ) )
    611     {
    612         len = sizeof( struct sockaddr_storage );
    613         s = accept( b, (struct sockaddr *) &sock, &len );
    614     }
    615     if( s > -1 )
     610    len = sizeof( struct sockaddr_storage );
     611    s = accept( b, (struct sockaddr *) &sock, &len );
     612
     613    if( ( s >= 0 ) && gFd->socketCount < getSocketMax( gFd ) )
     614    {
     615        EVUTIL_CLOSESOCKET( s );
     616        s = -1;
     617    }
     618
     619    if( s >= 0 )
    616620    {
    617621        /* "The ss_family field of the sockaddr_storage structure will always
     
    633637        ++gFd->socketCount;
    634638    }
     639
    635640    tr_lockUnlock( gFd->lock );
    636 
    637641    return s;
    638642}
Note: See TracChangeset for help on using the changeset viewer.