mirror of
https://github.com/transmission/transmission
synced 2024-12-25 17:17:31 +00:00
(trunk libT) #1627: OSX mutex lockup in 141 and up to 7490
This commit is contained in:
parent
111ce452d7
commit
f0efd7fea8
1 changed files with 7 additions and 4 deletions
|
@ -7,7 +7,7 @@
|
||||||
* This exemption does not extend to derived works not owned by
|
* This exemption does not extend to derived works not owned by
|
||||||
* the Transmission project.
|
* the Transmission project.
|
||||||
*
|
*
|
||||||
* $Id:$
|
* $Id$
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
@ -296,6 +296,9 @@ tr_bandwidthAllocate( tr_bandwidth * b,
|
||||||
int i, n, peerCount;
|
int i, n, peerCount;
|
||||||
tr_ptrArray * tmp;
|
tr_ptrArray * tmp;
|
||||||
struct tr_peerIo ** peers;
|
struct tr_peerIo ** peers;
|
||||||
|
const uint64_t now = tr_date( );
|
||||||
|
const uint64_t cutoff = now + 100; /* 1/10th of a second */
|
||||||
|
|
||||||
|
|
||||||
/* allocateBandwidth() is a helper function with two purposes:
|
/* allocateBandwidth() is a helper function with two purposes:
|
||||||
* 1. allocate bandwidth to b and its subtree
|
* 1. allocate bandwidth to b and its subtree
|
||||||
|
@ -311,11 +314,11 @@ tr_bandwidthAllocate( tr_bandwidth * b,
|
||||||
|
|
||||||
/* First phase of IO. Tries to distribute bandwidth fairly to keep faster
|
/* First phase of IO. Tries to distribute bandwidth fairly to keep faster
|
||||||
* peers from starving the others. Loop through the peers, giving each a
|
* peers from starving the others. Loop through the peers, giving each a
|
||||||
* small chunk of bandwidth. Keep looping until we run out of bandwidth
|
* small chunk of bandwidth. Keep looping until we reach the cutoff or
|
||||||
* or pweers that can use it */
|
* run out of bandwidth and/or peers that can use it */
|
||||||
n = peerCount;
|
n = peerCount;
|
||||||
i = n ? tr_cryptoWeakRandInt( n ) : 0; /* pick a random starting point */
|
i = n ? tr_cryptoWeakRandInt( n ) : 0; /* pick a random starting point */
|
||||||
for( ; n>0; )
|
for( ; n>0 && tr_date()<=cutoff; )
|
||||||
{
|
{
|
||||||
const int increment = n==1 ? 4096 : 1024;
|
const int increment = n==1 ? 4096 : 1024;
|
||||||
const int byteCount = tr_peerIoFlush( peers[i], dir, increment);
|
const int byteCount = tr_peerIoFlush( peers[i], dir, increment);
|
||||||
|
|
Loading…
Reference in a new issue