In perl.git, the branch blead has been updated <http://perl5.git.perl.org/perl.git/commitdiff/3b9aea04d23bb9e7d058953e075c38525e9baa11?hp=436e4aacde005119cc1005d5e9aecc3b707d16fc>
- Log ----------------------------------------------------------------- commit 3b9aea04d23bb9e7d058953e075c38525e9baa11 Author: Steve Hay <[email protected]> Date: Wed Sep 19 17:39:17 2012 +0100 Add new warning about sleep's limitation on Windows This also came up recently in [perl #33096]. On Windows, sleep's unsigned int argument range is effectively reduced by a factor of 1000 because the emulation uses milliseconds rather than seconds. M pod/perldiag.pod M win32/win32.c commit 3cd504478422d444c3a75de45b4fe50f5bab7843 Author: Steve Hay <[email protected]> Date: Wed Sep 19 17:32:10 2012 +0100 Note that sleep is emulated on Windows to allow alarm interrupts This came up recently in [perl #33096]. M pod/perlport.pod ----------------------------------------------------------------------- Summary of changes: pod/perldiag.pod | 6 ++++++ pod/perlport.pod | 4 +++- win32/win32.c | 6 +++++- 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/pod/perldiag.pod b/pod/perldiag.pod index e579b11..fee1506 100644 --- a/pod/perldiag.pod +++ b/pod/perldiag.pod @@ -4499,6 +4499,12 @@ Perhaps you put it into the wrong package? internal bookkeeping of op trees. An op tree needed to be freed after a compilation error, but could not be found, so it was leaked instead. +=item sleep(%u) too large + +(W overflow) You called C<sleep> with a number that was larger than +it can reliably handle and C<sleep> probably slept for less time than +requested. + =item Smart matching a non-overloaded object breaks encapsulation (F) You should not use the C<~~> operator on an object that does not diff --git a/pod/perlport.pod b/pod/perlport.pod index 6be7487..ac35534 100644 --- a/pod/perlport.pod +++ b/pod/perlport.pod @@ -1923,7 +1923,9 @@ Not implemented. (Win32, VMS, S<RISC OS>, VOS) =item sleep -Limited to a maximum of 4294967 seconds, approximately 49 days. (Win32) +Emulated using synchronization functions such that it can be +interrupted by alarm(), and limited to a maximum of 4294967 seconds, +approximately 49 days. (Win32) =item sockatmark diff --git a/win32/win32.c b/win32/win32.c index a16410f..8bb1369 100644 --- a/win32/win32.c +++ b/win32/win32.c @@ -2426,7 +2426,11 @@ win32_sleep(unsigned int t) { dTHX; /* Win32 times are in ms so *1000 in and /1000 out */ - return win32_msgwait(aTHX_ 0, NULL, t*1000, NULL)/1000; + if (t > UINT_MAX / 1000) { + Perl_ck_warner(aTHX_ packWARN(WARN_OVERFLOW), + "sleep(%lu) too large", t); + } + return win32_msgwait(aTHX_ 0, NULL, t * 1000, NULL) / 1000; } DllExport unsigned int -- Perl5 Master Repository
