Cygwin select() issues and improvements

Corinna Vinschen
Fri Feb 19 10:46:00 GMT 2016

On Feb 18 20:20, john hood wrote:
> On 2/15/16 7:57 AM, Corinna Vinschen wrote:
> > On Feb 14 03:09, john hood wrote:
> >> Various issues with Cygwin's select() annoyed me, and I've spent some
> >> time gnawing on them.
> > One of them is that they are not trivial enough to be acceptable without
> > copyright assignment (except patch 3, but see below).  Please have a
> > look at, the "Before you get started"
> > section.  There's a link to an "assign.txt" file with instructions.
> > 
> > The other one is just this:  Can you please describe each change in the
> > accompanying patch comment so that it's accessible from the git log?
> Sorry for the slow response here.  I have a bad cold and I'm not getting
> to things quickly.

I know what you mean.  I'm still coughing badly from the flu I catched

> Microsoft official documentation:
> <>
> <>
> Try running my socket-t program in
> <> as 'socket-t 10000'; it will
> report the actual time waited.  On Windows 10, you will see lots of
> variation in timeouts, with some of them shorter than the requested
> time.  My ancient Vista laptop has much less variation and is never
> shorter.  Win7 is similar.

In the second link it sounds like a change in W8 might causing this.

> The thing that I think should happen there is that fhandlers'
> select_{read,write,except}() functions should go away, and an fhandler
> should only have a poll() function that indicates what's available, and
> a get_waitable_object() function, that gives sel.wait() something to
> sleep on.  The select_{read,write,except}() functions, and the
> always_ready state variables, partially implement both of these pieces
> of functionality, and really complicate the implementation for select().
> I'm not sure I'll ever get to it, these Cygwin issues are very much a
> side project for me.

That's ok, but the idea is nice.  It would be cool if we could improve
select.  From my POV it has at least three downsides.  It's pretty slow,
the code is complicated, and it's badly commented.  Also, IIRC, the number
of descriptors is restricted to 63 due to WFMO restricted to this number
of handles.  This is not a restriction for sockets since sockets are
using threads per each 63 objects, but the other objects are not doing
that.  So, yeah, there's a lot to improve on select alone.

> The last patch in my series reverts from the documented
> CreateWaitableTimer() interfaces to the ancient, undocumented
> NTCreateTimer() interfaces only for consistency with the rest of the
> Cygwin codebase, which only uses NTCreateTimer().  The documented
> interfaces are all present in XP.  The undocumented interfaces have all
> the functionality this code needs.

Using NtCreateTimer is perfectly fine and I think the API is cleaner
than the CreateWaitableTimer API.

> I'm on #cygwin and #cygwin-dev, ask questions there if you want.

Not ATM, but feel free to contact me on the dev channel.


Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Maintainer                 cygwin AT cygwin DOT com
Red Hat
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <>

More information about the Cygwin-patches mailing list