[Box Backup-dev] Re: [Box Backup] Win32 port
Charles Lecklider
boxbackup-dev@fluffy.co.uk
Mon, 05 Dec 2005 18:27:28 +0000
Chris Wilson wrote:
> 7. Nick's BackupDaemon.cpp has the following code:
>
> + DWORD timeout = BoxTimeToMilliSeconds(RequiredDelay);
> +
> + while ( this->mReceivedCommandConn == false )
> + {
> + Sleep(1);
> +
> + if ( timeout == 0 )
> + {
> + DoSyncFlagOut = false;
> + SyncIsForcedOut = false;
> + return;
> + }
> + timeout--;
> + }
>
> This looks wrong to me. We sleep for one second, but decrease the
> timeout (in milliseconds) by one?
Sleep is a Windows API call which takes a number of milliseconds to
sleep. It really should be Sleep(0) - that gives up the timeslice,
rather than entering a kernel wait for all of 1ms. Same effect, more
friendly to the system.
-C