Fix bind tests for macos
This commit is contained in:
parent
850e4072e7
commit
6107bd554b
21
oio-unix.c
21
oio-unix.c
@ -213,8 +213,20 @@ int oio_bind(oio_handle* handle, struct sockaddr* addr) {
|
||||
}
|
||||
|
||||
r = bind(handle->fd, addr, addrsize);
|
||||
oio_err_new(handle, errno);
|
||||
return r;
|
||||
|
||||
if (r) {
|
||||
switch (errno) {
|
||||
case EADDRINUSE:
|
||||
handle->delayed_error = errno;
|
||||
return 0;
|
||||
|
||||
default:
|
||||
oio_err_new(handle, errno);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@ -317,6 +329,11 @@ int oio_accept(oio_handle* server, oio_handle* client,
|
||||
int oio_listen(oio_handle* handle, int backlog, oio_accept_cb cb) {
|
||||
assert(handle->fd >= 0);
|
||||
|
||||
if (handle->delayed_error) {
|
||||
oio_err_new(handle, handle->delayed_error);
|
||||
return -1;
|
||||
}
|
||||
|
||||
int r = listen(handle->fd, backlog);
|
||||
if (r < 0) {
|
||||
oio_err_new(handle, errno);
|
||||
|
||||
@ -49,6 +49,7 @@ typedef struct {
|
||||
#define oio_handle_private_fields \
|
||||
int fd; \
|
||||
int flags; \
|
||||
int delayed_error; \
|
||||
oio_read_cb read_cb; \
|
||||
oio_accept_cb accept_cb; \
|
||||
int accepted_fd; \
|
||||
|
||||
Loading…
Reference in New Issue
Block a user