Opened 14 years ago

Closed 14 years ago

Last modified 14 years ago

#980 closed Bug (fixed)

Optimistic unchoker is never called

Reported by: Waldorf Owned by: charles
Priority: Normal Milestone: 1.22
Component: libtransmission Version: 1.21
Severity: Major Keywords:
Cc:

Description

From forum:

rechoke() in peer-mgr.c has a bug:

    for( i=0; i<size && unchokedInterested<MAX_UNCHOKED_PEERS; ++i ) { 
        choke[i].doUnchoke = 1; 
        if( choke[i].isInterested ) 
            ++unchokedInterested; 
    } 
    n = i; 
    while( i<size ) 
        choke[i++].doUnchoke = 0; 

    /* optimistic unchoke */ 
    if( i < size ) 


Since i == size because of the while loop right above, that last line will never execute and optimistic unchoking won't be done. 

I've backtracked this issue in the source code and it seems this bug has been in place since r4580. 

I'm pretty sure the statement "n = i;" is there for a reason (variable n never gets used otherwise in the function), unfortunately
I don't understand much about how the bittorrent protocol functions, so I don't know what exactly is wrong there. 

http://forum.transmissionbt.com/viewtopic.php?p=24211

Change History (4)

comment:1 Changed 14 years ago by charles

  • Status changed from new to assigned

Looking at this code, I'm pretty sure that n was there so that i could be rewound back to it after setting the remaining `doUnchoke' fields to 0 right before the optimistic unchoke. However since those fields will already be 0 from the initial calloc(), I don't think even that is necessary. IMO those three lines can go away, leaving us with this:

for( i=0; i<size && unchokedInterested<MAX_UNCHOKED_PEERS; ++i ) {
    choke[i].doUnchoke = 1;
    if( choke[i].isInterested )
        ++unchokedInterested;
}

/* optimistic unchoke */
if( i < size )

comment:2 Changed 14 years ago by charles

  • Resolution set to fixed
  • Status changed from assigned to closed

comment:3 Changed 14 years ago by charles

  • Milestone changed from None Set to 1.30
  • Severity changed from Normal to Major

comment:4 Changed 14 years ago by charles

  • Milestone changed from 1.30 to 1.22
Note: See TracTickets for help on using tickets.