Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/bsd.c
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,11 @@ LIBUS_SOCKET_DESCRIPTOR bsd_create_socket(int domain, int type, int protocol) {

LIBUS_SOCKET_DESCRIPTOR created_fd = socket(domain, type | flags, protocol);

#if defined(SOCK_CLOEXEC) && defined(SOCK_NONBLOCK)
return apple_no_sigpipe(created_fd);
#else
return bsd_set_nonblocking(apple_no_sigpipe(created_fd));
#endif
}

void bsd_close_socket(LIBUS_SOCKET_DESCRIPTOR fd) {
Expand Down Expand Up @@ -400,7 +404,11 @@ LIBUS_SOCKET_DESCRIPTOR bsd_accept_socket(LIBUS_SOCKET_DESCRIPTOR fd, struct bsd

internal_finalize_bsd_addr(addr);

#if defined(SOCK_CLOEXEC) && defined(SOCK_NONBLOCK)
return apple_no_sigpipe(accepted_fd);
#else
return bsd_set_nonblocking(apple_no_sigpipe(accepted_fd));
#endif
}

int bsd_recv(LIBUS_SOCKET_DESCRIPTOR fd, void *buf, int length, int flags) {
Expand Down
3 changes: 2 additions & 1 deletion src/loop.c
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,8 @@ void us_internal_dispatch_ready_poll(struct us_poll_t *p, int error, int events)
/* If we filled the entire recv buffer, we need to immediately read again since otherwise a
* pending hangup event in the same even loop iteration can close the socket before we get
* the chance to read again next iteration */
if (length == LIBUS_RECV_BUFFER_LENGTH && s && !us_socket_is_closed(0, s)) {
if (length == LIBUS_RECV_BUFFER_LENGTH && s && !us_socket_is_closed(0, s)
&& (us_poll_events(&s->p) & LIBUS_SOCKET_READABLE)) {
goto read_more;
}

Expand Down