Ugly workaround for the deadlock introduced in [1445]

This commit is contained in:
Eric Petit 2007-01-29 12:16:56 +00:00
parent ddcfa59c96
commit 706a2ade11
1 changed files with 26 additions and 5 deletions

View File

@ -209,10 +209,22 @@ int tr_peerRead( tr_peer_t * peer )
/* Try to read */
for( ;; )
{
if( tor && ( ( !tor->customSpeedLimit && !tr_rcCanGlobalTransfer( tor->handle, 0 ) )
|| ( tor->customSpeedLimit && !tr_rcCanTransfer( tor->download ) ) ) )
if( tor )
{
break;
if( !tor->customSpeedLimit )
{
tr_lockUnlock( &tor->lock );
if( !tr_rcCanGlobalTransfer( tor->handle, 0 ) )
{
tr_lockLock( &tor->lock );
break;
}
tr_lockLock( &tor->lock );
}
else if( !tr_rcCanTransfer( tor->download ) )
{
break;
}
}
if( peer->size < 1 )
@ -386,8 +398,17 @@ writeBegin:
/* Send pieces if we can */
while( ( p = blockPending( tor, peer, &size ) ) )
{
if( ( !tor->customSpeedLimit && !tr_rcCanGlobalTransfer( tor->handle, 1 ) )
|| ( tor->customSpeedLimit && !tr_rcCanTransfer( tor->upload ) ) )
if( !tor->customSpeedLimit )
{
tr_lockUnlock( &tor->lock );
if( !tr_rcCanGlobalTransfer( tor->handle, 1 ) )
{
tr_lockLock( &tor->lock );
break;
}
tr_lockLock( &tor->lock );
}
else if( !tr_rcCanTransfer( tor->upload ) )
{
break;
}