mirror of
https://github.com/transmission/transmission
synced 2024-12-24 08:43:27 +00:00
(trunk libT) #2151: possible fix for "Unusually high CPU usage in latest builds" issue
This commit is contained in:
parent
8be9e3a44a
commit
3f03f2e0c3
1 changed files with 12 additions and 8 deletions
|
@ -599,20 +599,24 @@ tr_fdSocketAccept( int b,
|
|||
tr_address * addr,
|
||||
tr_port * port )
|
||||
{
|
||||
int s = -1;
|
||||
int s;
|
||||
unsigned int len;
|
||||
struct sockaddr_storage sock;
|
||||
tr_lockLock( gFd->lock );
|
||||
|
||||
assert( addr );
|
||||
assert( port );
|
||||
|
||||
tr_lockLock( gFd->lock );
|
||||
if( gFd->socketCount < getSocketMax( gFd ) )
|
||||
{
|
||||
len = sizeof( struct sockaddr_storage );
|
||||
s = accept( b, (struct sockaddr *) &sock, &len );
|
||||
|
||||
if( ( s >= 0 ) && gFd->socketCount < getSocketMax( gFd ) )
|
||||
{
|
||||
EVUTIL_CLOSESOCKET( s );
|
||||
s = -1;
|
||||
}
|
||||
if( s > -1 )
|
||||
|
||||
if( s >= 0 )
|
||||
{
|
||||
/* "The ss_family field of the sockaddr_storage structure will always
|
||||
* align with the family field of any protocol-specific structure." */
|
||||
|
@ -632,8 +636,8 @@ tr_fdSocketAccept( int b,
|
|||
}
|
||||
++gFd->socketCount;
|
||||
}
|
||||
tr_lockUnlock( gFd->lock );
|
||||
|
||||
tr_lockUnlock( gFd->lock );
|
||||
return s;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue