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
URL:
Depends on:
Blocks:
 
Reported: 2013-04-16 11:17 UTC by johannes.abt
Modified: 2015-04-02 22:07 UTC (History)
3 users (show)

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


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


Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report for Bug 11805 on GitHub or Developer Community if you have new information to add and do not yet see a matching new report.

If the latest results still closely match this report, you can use the original description:

  • Export the original title and description: GitHub Markdown or Developer Community HTML
  • Copy the title and description into the new report. Adjust them to be up-to-date if needed.
  • Add your new information.

In special cases on GitHub you might also want the comments: GitHub Markdown with public comments

Related Links:
Status:
NEW

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)) {
    sw.Stop();
    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.


mono-runtime 2.10.8.1-5

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