Bug 11805 - Socket.Poll returns too early
Summary: Socket.Poll returns too early
Status: NEW
Alias: None
Product: Class Libraries
Classification: Mono
Component: System (show other bugs)
Version: 2.10.x
Hardware: PC Linux
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
Depends on:
Reported: 2013-04-16 11:17 UTC by johannes.abt
Modified: 2015-04-02 22:07 UTC (History)
3 users (show)

See Also:
Is this bug a regression?: ---
Last known good build:

Patch for select/poll timeout returning too early (2.70 KB, patch)
2015-04-02 22:07 UTC, See Wong
Details | Diff

Description johannes.abt 2013-04-16 11:17:47 UTC

Comment 1 johannes.abt 2013-04-16 11:46:51 UTC
Socket.Poll() should return false only if the timeout is over and the conditions for returning true are not met. Correct?

In my multi-threaded application, Socket.Poll() often returns with false before the timeout is over.

var timeoutSeconds = 20;
var sw = System.Diagnostics.Stopwatch.StartNew();
if (!mySocket.Poll(1000000 * timeoutSeconds, SelectMode.SelectRead)) {
    if (timeoutSeconds * 1000 > sw.ElapsedMilliseconds)
        throw new Exception(String.Format("too early -- this should never happen timeout {0}s, elapsed {1}ms", timeoutSeconds,  sw.ElapsedMilliseconds));

Whenever I get the exception, I get it after less than one second.


Linux hostname 2.6.28-1-amd64 #1 SMP
Comment 2 johannes.abt 2013-04-16 11:59:24 UTC
I cannot retrace the error in a small testcase. Sorry.
Comment 3 johannes.abt 2013-04-16 12:07:43 UTC
By the way: It's a connected TCP socket.
Comment 4 See Wong 2015-04-02 22:07:14 UTC
Created attachment 10612 [details]
Patch for select/poll timeout returning too early

Note You need to log in before you can comment on or make changes to this bug.