diff --git a/TODO.FACTOR.txt b/TODO.FACTOR.txt index 60d9108db6..c2276e5daa 100644 --- a/TODO.FACTOR.txt +++ b/TODO.FACTOR.txt @@ -10,8 +10,6 @@ - mov 0x0(%esi),%ecx why? - mac intel: perhaps its not a good idea using ebx as allot-tmp-reg - RNG is broken -- gdb triggered 'interrupted system call' error -- fdasfsdfsa :help -- weird - %allot-bignum-signed-2 still has issues on ppc - fix %allot-bignum-signed-1/2 on x86 diff --git a/library/io/unix/io.factor b/library/io/unix/io.factor index ea2f0b23d1..7c4a728d1a 100644 --- a/library/io/unix/io.factor +++ b/library/io/unix/io.factor @@ -82,9 +82,12 @@ M: port set-timeout [ "Error on fd " % dup port-handle # ": " % swap % ] "" make swap set-port-error ; +: ignorable-error? ( n -- ? ) + dup EAGAIN number= swap EINTR number= or ; + : defer-error ( port -- ? ) #! Return t if it is an unrecoverable error. - err_no dup EAGAIN = over EINTR = or + err_no dup ignorable-error? [ 2drop f ] [ strerror swap report-error t ] if ; ! Associates a port with a list of continuations waiting on the @@ -145,8 +148,15 @@ GENERIC: task-container ( task -- vector ) read-fdset/tasks init-fdset write-fdset/tasks init-fdset f ; +: (io-multiplex) ( ms -- ) + [ FD_SETSIZE init-fdsets ] keep make-timeval select 0 < [ + err_no ignorable-error? [ (io-multiplex) ] [ drop ] if + ] [ + drop + ] if ; + : io-multiplex ( ms -- ) - >r FD_SETSIZE init-fdsets r> make-timeval select io-error + (io-multiplex) read-fdset/tasks handle-fdset write-fdset/tasks handle-fdset ;