Simplify error handling logic

db4
Slava Pestov 2008-05-15 05:50:50 -05:00
parent d7b296211e
commit f151a448c6
3 changed files with 11 additions and 22 deletions

View File

@ -113,8 +113,7 @@ HOOK: (wait-to-write) io-backend ( port -- )
dup buffer>> buffer-empty? [ drop ] [ (wait-to-write) ] if ;
M: output-port stream-flush ( port -- )
dup check-disposed
[ flush-port ] [ pending-error ] bi ;
[ check-disposed ] [ flush-port ] bi ;
M: output-port dispose*
[ flush-port ] [ call-next-method ] bi ;

View File

@ -48,11 +48,6 @@ M: mx remove-output-callbacks writes>> delete-at* drop ;
GENERIC: wait-for-events ( ms mx -- )
TUPLE: unix-io-error error port ;
: report-error ( error port -- )
tuck unix-io-error boa >>error drop ;
: input-available ( fd mx -- )
remove-input-callbacks [ resume ] each ;
@ -64,7 +59,7 @@ TUPLE: io-timeout ;
M: io-timeout summary drop "I/O operation timed out" ;
M: unix cancel-io ( port -- )
io-timeout new over report-error
io-timeout new >>error
handle>> handle-fd mx get-global
[ input-available ] [ output-available ] 2bi ;

View File

@ -86,12 +86,10 @@ M: object (accept) ( server addr -- handle )
[
[
<AcceptEx-args>
{
[ call-AcceptEx ]
[ wait-for-socket drop ]
[ sAcceptSocket*>> opened-socket ]
[ port>> pending-error ]
} cleave
[ call-AcceptEx ]
[ wait-for-socket drop ]
[ sAcceptSocket*>> opened-socket ]
tri
] curry with-timeout
] with-destructors ;
@ -126,12 +124,10 @@ TUPLE: WSARecvFrom-args port
M: winnt (receive) ( datagram -- packet addrspec )
[
<WSARecvFrom-args>
{
[ call-WSARecvFrom ]
[ wait-for-socket ]
[ port>> pending-error ]
[ parse-WSARecvFrom ]
} cleave
[ call-WSARecvFrom ]
[ wait-for-socket ]
[ parse-WSARecvFrom ]
tri
] with-destructors ;
TUPLE: WSASendTo-args port
@ -166,6 +162,5 @@ M: winnt (send) ( packet addrspec datagram -- )
<WSASendTo-args>
[ call-WSASendTo ]
[ wait-for-socket drop ]
[ port>> pending-error ]
tri
bi
] with-destructors ;