Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

macos timeout fix #180

Merged
merged 1 commit into from
May 2, 2024
Merged
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
7 changes: 6 additions & 1 deletion src/io_posix.c
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,8 @@ udx__on_writable (udx_socket_t *socket) {
#ifdef UDX_PLATFORM_HAS_SENDMMSG
bool finished = false;

assert((socket->status & UDX_SOCKET_CLOSING_HANDLES) == 0);

while (!finished) {
udx_packet_t *batch[UDX_SENDMMSG_BATCH_SIZE];
struct mmsghdr h[UDX_SENDMMSG_BATCH_SIZE];
Expand Down Expand Up @@ -180,7 +182,7 @@ udx__on_writable (udx_socket_t *socket) {
udx__confirm_packet(batch[i]);
}

if (rc == UV_EAGAIN) {
if (rc == UV_EAGAIN || socket->status & UDX_SOCKET_CLOSING_HANDLES) {
finished = true;
}
}
Expand Down Expand Up @@ -209,6 +211,9 @@ udx__on_writable (udx_socket_t *socket) {
// todo: set in confirm packet with uv_now()
pkt->time_sent = uv_now(socket->udx->loop);
udx__confirm_packet(pkt);
if (socket->status & UDX_SOCKET_CLOSING_HANDLES) {
break;
}
}
#endif
}
4 changes: 4 additions & 0 deletions src/io_win.c
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ udx__recvmsg (udx_socket_t *socket, uv_buf_t *buf, struct sockaddr *addr, int ad

void
udx__on_writable (udx_socket_t *socket) {
assert((socket->status & UDX_SOCKET_CLOSING_HANDLES) == 0);
while (true) {
udx_packet_t *pkt = udx__shift_packet(socket);
if (pkt == NULL) break;
Expand All @@ -108,5 +109,8 @@ udx__on_writable (udx_socket_t *socket) {
}
pkt->time_sent = uv_now(socket->udx->loop);
udx__confirm_packet(pkt);
if (socket->status & UDX_SOCKET_CLOSING_HANDLES) {
break;
}
}
}
4 changes: 2 additions & 2 deletions src/udx.c
Original file line number Diff line number Diff line change
Expand Up @@ -1598,7 +1598,7 @@ on_uv_poll (uv_poll_t *handle, int status, int events) {
buf.base = (char *) &b;
buf.len = 2048;

while ((size = udx__recvmsg(socket, &buf, (struct sockaddr *) &addr, addr_len)) >= 0) {
while (!(socket->status & UDX_SOCKET_CLOSING_HANDLES) && (size = udx__recvmsg(socket, &buf, (struct sockaddr *) &addr, addr_len)) >= 0) {
if (!process_packet(socket, b, size, (struct sockaddr *) &addr) && socket->on_recv != NULL) {
buf.len = size;

Expand All @@ -1613,7 +1613,7 @@ on_uv_poll (uv_poll_t *handle, int status, int events) {
}
}

if (events & UV_WRITABLE) {
if (events & UV_WRITABLE && !(socket->status & UDX_SOCKET_CLOSING_HANDLES)) {
if (events & UV_READABLE) {
// compensate for potentially long-running read callbacks
uv_update_time(handle->loop);
Expand Down
Loading