Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel C. Weber <dw@exram.de>2017-03-09 05:09:50 +0300
committerJonathan Pryor <jonpryor@vt.edu>2017-03-09 05:09:50 +0300
commiteea2d3e2504bc4522e9977621e9f495ef5e26773 (patch)
tree07d1fc4bd6ae2e4a2d39b1d66c086855baf74fe3 /mcs/class/Mono.Posix
parentd455c0d23462d34352e4accd9953b1f487351c7f (diff)
[Mono.Posix] UnixSIgnal.WaitOne() doesn't block for 0 timeout (#4489)
For timeouts of 0 milliseconds, WaitOne may produce incorrect results. In case of timeout, the result of WaitAny denotes the amount of milliseconds that have timed out. WaitOne relies on WaitAny and interprets the result falsely as the index of the completed handle. This change introduces a check on the timeout and returns `IsSet` when the handle is not allowed to block. This is in accordance to Microsofts [documentation of WaitOne](https://msdn.microsoft.com/de-de/library/cc189983(v=vs.110).aspx) which states "If millisecondsTimeout is zero, the method does not block. It tests the state of the wait handles and returns immediately.". [Here](https://github.com/StephenCleary/AsyncEx.Interop.WaitHandles/blob/master/src/Nito.AsyncEx.Interop.WaitHandles/WaitHandleInterop.cs#L51) is an example of some code relying on correct output of `WaitOne(0)` that is effectively broken by the current behaviour.
Diffstat (limited to 'mcs/class/Mono.Posix')
-rw-r--r--mcs/class/Mono.Posix/Mono.Unix/UnixSignal.cs2
1 files changed, 2 insertions, 0 deletions
diff --git a/mcs/class/Mono.Posix/Mono.Unix/UnixSignal.cs b/mcs/class/Mono.Posix/Mono.Unix/UnixSignal.cs
index ee28ffdee4d..39d25ca11a0 100644
--- a/mcs/class/Mono.Posix/Mono.Unix/UnixSignal.cs
+++ b/mcs/class/Mono.Posix/Mono.Unix/UnixSignal.cs
@@ -188,6 +188,8 @@ namespace Mono.Unix {
AssertValid ();
if (exitContext)
throw new InvalidOperationException ("exitContext is not supported");
+ if (millisecondsTimeout == 0)
+ return IsSet;
return WaitAny (new UnixSignal[]{this}, millisecondsTimeout) == 0;
}
#endregion