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
parent
6421af3401
commit
753b2f0177
|
@ -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 ] }
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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 -- )
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in New Issue