Opened 9 years ago

Closed 9 years ago

Last modified 9 years ago

#5121 closed Bug (fixed)

Stopped torrents resume after sleep automatically.

Reported by: gsch Owned by: livings124
Priority: Normal Milestone: 2.74
Component: Mac Client Version: 2.73
Severity: Normal Keywords: mac
Cc:

Description

There is a possibility that a stopped torrent resumes downloading after waking up from sleep. (Only on a mac.)

The reason is simple / how to reproduce.

  1. The mac gets put to sleep while a torrent is running.

fResumeOnWake gets set to true.

  1. When waking up the mac, the torrent resumes as it should.
  2. Stop all running torrents (it's not sufficient to only stop one).
  3. Put the mac to sleep.
  4. Wake it up, the torrent resumes because fResumeOnWake is still true.

There are 2 possible fixes..

Either reset the fResumeOnWake state in Torrent.m:

 - (void) wakeUp
{
    if (fResumeOnWake)
    {
        fResumeOnWake = NO;
        tr_ninf( fInfo->name, "restarting because of wakeUp" );
        tr_torrentStart(fHandle);
    }
}

or calling 'sleep' for each torrent when the mac suspends in Controller.m:

- (void) sleepCallback: (natural_t) messageType argument: (void *) messageArgument
{
    switch (messageType)
    {
        case kIOMessageSystemWillSleep:
            //stop all transfers (since some are active) before going to sleep and remember to resume when we wake up
            for (Torrent * torrent in fTorrents)
                [torrent sleep];
            
            //if there are any running transfers, wait 15 seconds for them to stop
            for (Torrent * torrent in fTorrents)
                if ([torrent isActive])
                {
                    sleep(15);
                    break;
                }

            IOAllowPowerChange(fRootPort, (long) messageArgument);
            break;
...

I've tried both methods. However, I prefer the second, because resetting the fResumeOnWake seems to be kind of a hack.

Attachments (1)

resume_fix.diff (1.1 KB) - added by gsch 9 years ago.

Download all attachments as: .zip

Change History (5)

Changed 9 years ago by gsch

comment:1 Changed 9 years ago by livings124

Thanks! I made a slight adjustment to the patch and submitted in r13611.

comment:2 Changed 9 years ago by livings124

  • Milestone changed from None Set to 2.80
  • Resolution set to fixed
  • Status changed from new to closed

comment:3 Changed 9 years ago by livings124

tweaked in r13612

comment:4 Changed 9 years ago by jordan

  • Milestone changed from 2.80 to 2.74
Note: See TracTickets for help on using tickets.