Fixes bug 205437: socket errors not being reported
This commit is contained in:
parent
884f3fe921
commit
fc92ec8e9f
|
@ -17,6 +17,7 @@
|
||||||
(let ([s (tcp-server-socket-nonblocking
|
(let ([s (tcp-server-socket-nonblocking
|
||||||
(or (string->number port)
|
(or (string->number port)
|
||||||
(error who "invalid port number" port)))])
|
(error who "invalid port number" port)))])
|
||||||
|
(printf "Listening on port ~a\n" port)
|
||||||
(call/cc
|
(call/cc
|
||||||
(lambda (k)
|
(lambda (k)
|
||||||
(with-exception-handler k
|
(with-exception-handler k
|
||||||
|
|
|
@ -2073,7 +2073,7 @@
|
||||||
(define (set-fd-nonblocking fd who id)
|
(define (set-fd-nonblocking fd who id)
|
||||||
(let ([rv (foreign-call "ikrt_make_fd_nonblocking" fd)])
|
(let ([rv (foreign-call "ikrt_make_fd_nonblocking" fd)])
|
||||||
(unless (eq? rv 0)
|
(unless (eq? rv 0)
|
||||||
(io-error who id fd))))
|
(io-error who id rv))))
|
||||||
|
|
||||||
(define (socket->ports socket who id block?)
|
(define (socket->ports socket who id block?)
|
||||||
(if (< socket 0)
|
(if (< socket 0)
|
||||||
|
|
|
@ -158,27 +158,29 @@ do_connect(ikptr host, ikptr srvc, int socket_type){
|
||||||
return fix(-1);
|
return fix(-1);
|
||||||
}
|
}
|
||||||
struct addrinfo* i = info;
|
struct addrinfo* i = info;
|
||||||
int sock = -1;
|
ikptr sock = fix(-1);
|
||||||
while(i){
|
while(i){
|
||||||
if(i->ai_socktype != socket_type){
|
if(i->ai_socktype != socket_type){
|
||||||
i = i->ai_next;
|
i = i->ai_next;
|
||||||
} else {
|
} else {
|
||||||
int s = socket(i->ai_family, i->ai_socktype, i->ai_protocol);
|
int s = socket(i->ai_family, i->ai_socktype, i->ai_protocol);
|
||||||
if(s < 0){
|
if(s < 0){
|
||||||
|
sock = ikrt_io_error();
|
||||||
i = i->ai_next;
|
i = i->ai_next;
|
||||||
} else {
|
} else {
|
||||||
int err = connect(s, i->ai_addr, i->ai_addrlen);
|
int err = connect(s, i->ai_addr, i->ai_addrlen);
|
||||||
if(err < 0){
|
if(err < 0){
|
||||||
|
sock = ikrt_io_error();
|
||||||
i = i->ai_next;
|
i = i->ai_next;
|
||||||
} else {
|
} else {
|
||||||
sock = s;
|
sock = fix(s);
|
||||||
i = 0;
|
i = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
freeaddrinfo(info);
|
freeaddrinfo(info);
|
||||||
return fix(sock);
|
return sock;
|
||||||
}
|
}
|
||||||
|
|
||||||
ikptr
|
ikptr
|
||||||
|
|
Loading…
Reference in New Issue