Skip to content

Commit

Permalink
Make receiving data over TCP faster on Windows (#10191)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jarred-Sumner authored Apr 12, 2024
1 parent ff5ef51 commit d00b5b9
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion packages/bun-usockets/src/loop.c
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,13 @@ void us_internal_dispatch_ready_poll(struct us_poll_t *p, int error, int events)

do {
const struct us_loop_t* loop = s->context->loop;
int length = bsd_recv(us_poll_fd(&s->p), loop->data.recv_buf + LIBUS_RECV_BUFFER_PADDING, LIBUS_RECV_BUFFER_LENGTH, MSG_DONTWAIT);
#ifdef _WIN32
const int recv_flags = MSG_PUSH_IMMEDIATE;
#else
const int recv_flags = MSG_DONTWAIT | MSG_NOSIGNAL;
#endif

int length = bsd_recv(us_poll_fd(&s->p), loop->data.recv_buf + LIBUS_RECV_BUFFER_PADDING, LIBUS_RECV_BUFFER_LENGTH, recv_flags);

if (length > 0) {
s = s->context->on_data(s, loop->data.recv_buf + LIBUS_RECV_BUFFER_PADDING, length);
Expand Down

0 comments on commit d00b5b9

Please sign in to comment.