PROPOSAL(S): threadWaitError and threadWaitErrorSTM

Hola! Control.Concurrent currently has: threadWaitRead :: Fd -> IO () threadWaitWrite :: Fd -> IO () threadWaitReadSTM :: Fd -> IO (STM (), IO ()) threadWaitWriteSTM :: Fd -> IO (STM (), IO ()) (btw, whoever added the STM versions, I <3 you) I would like to propose adding: threadWaitError :: Fd -> IO () threadWaitErrorSTM :: Fd -> IO (STM (), IO ()) to allow for blocking on detecting error condition on file descriptors, similar to what C's select() allows. Cheers, Merijn

On Sun, Mar 16, 2014 at 10:25 AM, Merijn Verstraaten wrote: threadWaitError :: Fd -> IO ()
threadWaitErrorSTM :: Fd -> IO (STM (), IO ()) to allow for blocking on detecting error condition on file descriptors,
similar to what C's select() allows. If you mean the third bitmask, it is not for errors (notwithstanding the
documentation on some systems); an "exceptional condition" is not an error,
it's MSG_OOB data. Errors show as "ready" on the appropriate mask (read or
write) since a read (resp. write) will return immediately with the error
instead of blocking.
See
http://stackoverflow.com/questions/1342712/nix-select-and-exceptfds-errorfds...
http://man7.org/linux/man-pages/man2/select_tut.2.html for more information.
--
brandon s allbery kf8nh sine nomine associates
allbery.b@gmail.com ballbery@sinenomine.net
unix, openafs, kerberos, infrastructure, xmonad http://sinenomine.net

I just went with the common documentation name, I know this includes out-of-band data, etc. If it makes you happier, feel free to consider this proposal with s/Error/Exceptional, regardless of how it's called, it'd be nice if we could use this from within Haskell. Cheers, Merijn On Mar 16, 2014, at 16:09 , Brandon Allbery wrote:
On Sun, Mar 16, 2014 at 10:25 AM, Merijn Verstraaten
wrote: threadWaitError :: Fd -> IO () threadWaitErrorSTM :: Fd -> IO (STM (), IO ()) to allow for blocking on detecting error condition on file descriptors, similar to what C's select() allows.
If you mean the third bitmask, it is not for errors (notwithstanding the documentation on some systems); an "exceptional condition" is not an error, it's MSG_OOB data. Errors show as "ready" on the appropriate mask (read or write) since a read (resp. write) will return immediately with the error instead of blocking.
See http://stackoverflow.com/questions/1342712/nix-select-and-exceptfds-errorfds... and http://man7.org/linux/man-pages/man2/select_tut.2.html for more information.
-- brandon s allbery kf8nh sine nomine associates allbery.b@gmail.com ballbery@sinenomine.net unix, openafs, kerberos, infrastructure, xmonad http://sinenomine.net

Hi Merijn,
I see how you'd wait for exceptional conditions using select(). Epoll is a
bit different... How would you do it with epoll? Is it using the EPOLLPRI
event type?
Andi
On Sun, Mar 16, 2014 at 1:16 PM, Merijn Verstraaten
I just went with the common documentation name, I know this includes out-of-band data, etc. If it makes you happier, feel free to consider this proposal with s/Error/Exceptional, regardless of how it's called, it'd be nice if we could use this from within Haskell.
Cheers, Merijn
On Mar 16, 2014, at 16:09 , Brandon Allbery wrote:
On Sun, Mar 16, 2014 at 10:25 AM, Merijn Verstraaten < merijn@inconsistent.nl> wrote:
threadWaitError :: Fd -> IO () threadWaitErrorSTM :: Fd -> IO (STM (), IO ())
to allow for blocking on detecting error condition on file descriptors, similar to what C's select() allows.
If you mean the third bitmask, it is not for errors (notwithstanding the documentation on some systems); an "exceptional condition" is not an error, it's MSG_OOB data. Errors show as "ready" on the appropriate mask (read or write) since a read (resp. write) will return immediately with the error instead of blocking.
See http://stackoverflow.com/questions/1342712/nix-select-and-exceptfds-errorfds... http://man7.org/linux/man-pages/man2/select_tut.2.html for more information.
-- brandon s allbery kf8nh sine nomine associates allbery.b@gmail.com ballbery@sinenomine.net unix, openafs, kerberos, infrastructure, xmonad http://sinenomine.net
_______________________________________________ Libraries mailing list Libraries@haskell.org http://www.haskell.org/mailman/listinfo/libraries

Seems rather simple, just use epoll's EPOLLERR event type. There's more types (like the EPOLLPRI type you mentioned), but I would not argue for adding those as such events may not be portable to platforms that don't support epoll (i.e. platforms that only have kqueue/select), whereas EPOLLERR should be available in some form for all platforms. Cheers, Merijn On Mar 17, 2014, at 14:23 , Andreas Voellmy wrote:
Hi Merijn,
I see how you'd wait for exceptional conditions using select(). Epoll is a bit different... How would you do it with epoll? Is it using the EPOLLPRI event type?
Andi
On Sun, Mar 16, 2014 at 1:16 PM, Merijn Verstraaten
wrote: I just went with the common documentation name, I know this includes out-of-band data, etc. If it makes you happier, feel free to consider this proposal with s/Error/Exceptional, regardless of how it's called, it'd be nice if we could use this from within Haskell. Cheers, Merijn
On Mar 16, 2014, at 16:09 , Brandon Allbery wrote:
On Sun, Mar 16, 2014 at 10:25 AM, Merijn Verstraaten
wrote: threadWaitError :: Fd -> IO () threadWaitErrorSTM :: Fd -> IO (STM (), IO ()) to allow for blocking on detecting error condition on file descriptors, similar to what C's select() allows.
If you mean the third bitmask, it is not for errors (notwithstanding the documentation on some systems); an "exceptional condition" is not an error, it's MSG_OOB data. Errors show as "ready" on the appropriate mask (read or write) since a read (resp. write) will return immediately with the error instead of blocking.
See http://stackoverflow.com/questions/1342712/nix-select-and-exceptfds-errorfds... and http://man7.org/linux/man-pages/man2/select_tut.2.html for more information.
-- brandon s allbery kf8nh sine nomine associates allbery.b@gmail.com ballbery@sinenomine.net unix, openafs, kerberos, infrastructure, xmonad http://sinenomine.net
_______________________________________________ Libraries mailing list Libraries@haskell.org http://www.haskell.org/mailman/listinfo/libraries

epoll automatically always waits on EPOLLERR, and it looks like this will
just lead to threadWait functions to return from the call.
Can you write a small test case to check if the current behavior works (or
not) with existing threadWait functions?
Andi
On Tue, Mar 18, 2014 at 6:46 AM, Merijn Verstraaten
Seems rather simple, just use epoll's EPOLLERR event type. There's more types (like the EPOLLPRI type you mentioned), but I would not argue for adding those as such events may not be portable to platforms that don't support epoll (i.e. platforms that only have kqueue/select), whereas EPOLLERR should be available in some form for all platforms.
Cheers, Merijn
On Mar 17, 2014, at 14:23 , Andreas Voellmy wrote:
Hi Merijn,
I see how you'd wait for exceptional conditions using select(). Epoll is a bit different... How would you do it with epoll? Is it using the EPOLLPRI event type?
Andi
On Sun, Mar 16, 2014 at 1:16 PM, Merijn Verstraaten < merijn@inconsistent.nl> wrote:
I just went with the common documentation name, I know this includes out-of-band data, etc. If it makes you happier, feel free to consider this proposal with s/Error/Exceptional, regardless of how it's called, it'd be nice if we could use this from within Haskell.
Cheers, Merijn
On Mar 16, 2014, at 16:09 , Brandon Allbery wrote:
On Sun, Mar 16, 2014 at 10:25 AM, Merijn Verstraaten < merijn@inconsistent.nl> wrote:
threadWaitError :: Fd -> IO () threadWaitErrorSTM :: Fd -> IO (STM (), IO ())
to allow for blocking on detecting error condition on file descriptors, similar to what C's select() allows.
If you mean the third bitmask, it is not for errors (notwithstanding the documentation on some systems); an "exceptional condition" is not an error, it's MSG_OOB data. Errors show as "ready" on the appropriate mask (read or write) since a read (resp. write) will return immediately with the error instead of blocking.
See http://stackoverflow.com/questions/1342712/nix-select-and-exceptfds-errorfds... http://man7.org/linux/man-pages/man2/select_tut.2.html for more information.
-- brandon s allbery kf8nh sine nomine associates allbery.b@gmail.com ballbery@sinenomine.net unix, openafs, kerberos, infrastructure, xmonad http://sinenomine.net
_______________________________________________ Libraries mailing list Libraries@haskell.org http://www.haskell.org/mailman/listinfo/libraries
participants (3)
-
Andreas Voellmy
-
Brandon Allbery
-
Merijn Verstraaten