io.files: make wait-for-fd generic and dispatch depending on backend

do-ssl-accept need to call wait-for-fd so it needs to be generic. On
windows it's a noop but on unix it will wait for the fd.
db4
Björn Lindqvist 2013-10-21 18:27:29 +02:00 committed by Doug Coleman
parent 6421af3401
commit 753b2f0177
4 changed files with 7 additions and 5 deletions

View File

@ -69,7 +69,7 @@ ERROR: io-timeout ;
M: io-timeout summary drop "I/O operation timed out" ;
: wait-for-fd ( handle event -- )
M: unix wait-for-fd ( handle event -- )
dup +retry+ eq? [ 2drop ] [
[ [ self ] dip handle-fd mx get-global ] dip {
{ +input+ [ add-input-callback ] }

View File

@ -206,6 +206,9 @@ M: windows (wait-to-write) ( port -- )
M: windows (wait-to-read) ( port -- )
[ dup handle>> refill ] with-destructors drop ;
M: windows wait-for-fd ( handle event -- )
2drop ;
: console-app? ( -- ? ) GetConsoleWindow >boolean ;
M: windows init-stdio

View File

@ -202,13 +202,10 @@ SYMBOL: default-secure-context
{ SSL_ERROR_SSL [ (ssl-error) ] }
} case ;
! Does this work on windows?
: do-ssl-accept ( ssl-handle -- )
dup dup handle>> SSL_accept check-accept-response dup
[
[ dup file>> ] dip
2drop ! wait-for-fd, todo: figure out wait-for-fd for windows
do-ssl-accept
[ dup file>> ] dip wait-for-fd do-ssl-accept
] [ 2drop ] if ;
: maybe-handshake ( ssl-handle -- )

View File

@ -14,6 +14,8 @@ SYMBOL: +output+
GENERIC: drain ( port handle -- event/f )
GENERIC: refill ( port handle -- event/f )
HOOK: wait-for-fd ( handle event -- )
MIXIN: file-reader
MIXIN: file-writer