mtstickney / sbcl

Mirror of Steel Bank Common Lisp (SBCL)'s official repository
http://www.sbcl.org/
Other
1 stars 0 forks source link

WAIT-FOR-FD-USABLE busy-loops on windows #5

Open mtstickney opened 4 years ago

mtstickney commented 4 years ago

The issue here is that waiting is done by polling with handle-listen, but the timeout value isn't passed like it is with sb-unix:simple-unix-poll. It's possible not all handle types will support polling timeouts, but sockets certainly would. We should do that, because busy-looping is for suckers (cl+ssl uses wait-for-fd-usable and is probably subject to this problem).

mtstickney commented 4 years ago

Note to self: assuming the patch for #1 gets merged, the socket part of this is easy (just pass the timeout through to select). Pipes might not be possible: Windows apparently has ways to read from a pipe asynchronously (the usual overlapped I/O or completion-port stuff), but not to wait until there is data available (pipes cannot be used with the WaitFor* functions, as they are not a supported object type).

Consoles can be waited on with the WaitFor* functions, but you're going to want to be sure those will correctly end on EOF as well as actual input. Also means messing with win32_tty_listen, which is doing some... interesting things with condition variables and whatnot. E.g. you can't just replace PeekConsoleInput with a wait either, because a lock is held there.

hineios commented 3 years ago

FYI, https://github.com/sbcl/sbcl/commit/561fb489902464ed0f3a4003d1588a2a35ded7ac

mtstickney commented 3 years ago

Oh, nice! Thanks for the heads up; I'm going to have to get back to this stuff one of these days.