Rework CONNECT-SOCKET to use SELECT.
Note: this is presently broken because of a wrong input-port/output port classification of the port passed into SELECT.
This commit is contained in:
parent
d0977ea4d4
commit
c7e49f9274
|
@ -230,27 +230,27 @@
|
|||
(else
|
||||
(let loop ()
|
||||
((structure-ref interrupts disable-interrupts!))
|
||||
(let ((res (%connect (socket->fdes sock)
|
||||
(socket:family sock)
|
||||
(socket-address:address name))))
|
||||
(let* ((fdes (socket->fdes sock))
|
||||
(res (%connect fdes
|
||||
(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)
|
||||
;; If connect returned EINPROGRESS, we can check
|
||||
;; it's success after the next success with getsockopt
|
||||
(let ((val (socket-option sock
|
||||
level/socket
|
||||
socket/error)))
|
||||
(if (not (zero? val))
|
||||
(errno-error val
|
||||
(errno-msg val)
|
||||
%connect
|
||||
sock
|
||||
name)))
|
||||
(loop))))))))))))
|
||||
(else
|
||||
(select '#() (vector fdes) '#())
|
||||
(if (car res)
|
||||
;; If connect returned EINPROGRESS, we can check
|
||||
;; it's success after the next success with getsockopt
|
||||
(let ((val (socket-option sock
|
||||
level/socket
|
||||
socket/error)))
|
||||
(if (not (zero? val))
|
||||
(errno-error val
|
||||
(errno-msg val)
|
||||
%connect
|
||||
sock
|
||||
name)))
|
||||
(loop))))))))))))
|
||||
|
||||
(import-os-error-syscall %connect (sockfd family name) "scheme_connect")
|
||||
|
||||
|
|
|
@ -131,13 +131,9 @@ s48_value scheme_connect(s48_value sock, s48_value family, s48_value scheme_name
|
|||
&& errno != EINPROGRESS && errno != EAGAIN)
|
||||
s48_raise_os_error_3(errno, sock, family, scheme_name);
|
||||
|
||||
if (! (s48_add_pending_fd(sockfd, 0)))
|
||||
s48_raise_out_of_memory_error();
|
||||
|
||||
if (errno == EINPROGRESS)
|
||||
return s48_enter_fixnum (0);
|
||||
else return S48_FALSE;
|
||||
|
||||
return
|
||||
s48_cons ((errno == EINPROGRESS) ? S48_TRUE : S48_FALSE,
|
||||
s48_enter_fixnum (sockfd));
|
||||
}
|
||||
default:
|
||||
s48_raise_argument_type_error (family); /* error unknown address family */
|
||||
|
|
Loading…
Reference in New Issue