Re: [RFC 00/17] Merge event loop implementations

Eli Zaretskii
2019-02-25T20:30:02Z

> From: Tom Tromey <tom@tromey.com>
> Cc: Tom Tromey <tom@tromey.com>, gdb-patches@sourceware.org
> Date: Mon, 25 Feb 2019 12:57:49 -0700
>
> By my reading of the code, gdbserver on Windows can call select with
> just two file descriptors: one that is a socket that is being 'listen'd
> to, and another which is the result of 'accept'.

Can you point me to the gdbserver code which calls 'socket' and
'accept' on Windows, whose results are used in 'select'? I'd like to
see what it does on Windows, to be able to have a better idea of what
adaptations would be necessary for Gnulib's 'select'.

> Eli> The long-term goal is probably to import the Gnulib implementation of
> Eli> 'select', which AFAIR supports any kind of descriptors. But that
> Eli> would need some adaptation work.
>
> Do you know offhand what is needed? I didn't know that gnulib had
> this... this does seem like a good way to go if possible.

Offhand, I think we'd need just the trivial adaptations, like make
sure gdbserver uses file descriptors instead of HSOCKETs on Windows as
well. Probably it would be best to import Gnulib's 'socket' and
'accept' as well, and use their SOCKET_TO_FD and FD_TO_SOCKET macros
if/where needed (hopefully nowhere). Are there any more related APIs,
besides those 3? I guess, 'close' (which should call 'closesocket' on
Windows) and perhaps 'ioctl'? Gnulib has those as well.