Connect can now handle non-blocking sockets that return EINPROGRESS.
This commit is contained in:
parent
f095b068a8
commit
52291acc0e
|
@ -55,9 +55,10 @@
|
|||
(dynamic-wind
|
||||
(lambda () #f)
|
||||
(lambda () (connect-socket sock addr) (set! connected #t))
|
||||
(lambda ()
|
||||
(if (not connected)
|
||||
(close-socket sock))))
|
||||
(lambda () #f
|
||||
;(if (not connected)
|
||||
; (close-socket sock))
|
||||
))
|
||||
(if connected
|
||||
sock
|
||||
#f))))
|
||||
|
@ -228,14 +229,25 @@
|
|||
(else
|
||||
(let loop ()
|
||||
((structure-ref interrupts disable-interrupts!))
|
||||
(if (%connect (socket->fdes sock)
|
||||
(socket:family sock)
|
||||
(socket-address:address name))
|
||||
((structure-ref interrupts enable-interrupts!))
|
||||
(begin (wait-for-channel
|
||||
(fdport-data:channel
|
||||
(fdport-data (socket:inport sock))))
|
||||
(loop))))))))))
|
||||
(let ((res (%connect (socket->fdes sock)
|
||||
(socket:family sock)
|
||||
(socket-address:address name))))
|
||||
(cond ((eq? res #t)
|
||||
((structure-ref interrupts enable-interrupts!)))
|
||||
(else (wait-for-channel
|
||||
(fdport-data:channel
|
||||
(fdport-data (socket:inport sock))))
|
||||
(if (eq? res 0)
|
||||
(handle-EINPROGRESS sock)
|
||||
(loop))))))))))))
|
||||
|
||||
;;; If connect returned EINPROGRESS, we can check it's success after
|
||||
;;; the next success with getsockopt
|
||||
|
||||
(define (handle-EINPROGRESS sock)
|
||||
(let ((val (socket-option sock level/socket socket/error)))
|
||||
(if (not (zero? val))
|
||||
(errno-error val "scheme_connnect"))))
|
||||
|
||||
(define-stubless-foreign %connect (sockfd family name) "scheme_connect")
|
||||
|
||||
|
|
|
@ -119,7 +119,9 @@ s48_value scheme_connect(s48_value sock, s48_value family, s48_value scheme_name
|
|||
if (! (s48_add_pending_fd(sockfd, 0)))
|
||||
s48_raise_out_of_memory_error();
|
||||
|
||||
return S48_FALSE;
|
||||
if (errno == EINPROGRESS)
|
||||
return s48_enter_fixnum (0);
|
||||
else return S48_FALSE;
|
||||
|
||||
}
|
||||
default:
|
||||
|
|
Loading…
Reference in New Issue