Skip to content

Commit e16acf9

Browse files
committed
re-arm
1 parent 53100d1 commit e16acf9

File tree

1 file changed

+10
-1
lines changed
  • packages/bun-usockets/src

1 file changed

+10
-1
lines changed

packages/bun-usockets/src/loop.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -375,7 +375,11 @@ void us_internal_dispatch_ready_poll(struct us_poll_t *p, int error, int eof, in
375375
/* Note: if we failed a write as a socket of one loop then adopted
376376
* to another loop, this will be wrong. Absurd case though */
377377
loop->data.last_write_failed = 0;
378-
378+
#ifdef LIBUS_USE_KQUEUE
379+
/* Kqueue is one-shot so is not writable anymore */
380+
p->state.poll_type = us_internal_poll_type(p) | ((events & LIBUS_SOCKET_READABLE) ? POLL_TYPE_POLLING_IN : 0);
381+
#endif
382+
379383
s = s->context->on_writable(s);
380384

381385
if (!s || us_socket_is_closed(0, s)) {
@@ -385,6 +389,11 @@ void us_internal_dispatch_ready_poll(struct us_poll_t *p, int error, int eof, in
385389
/* If we have no failed write or if we shut down, then stop polling for more writable */
386390
if (!loop->data.last_write_failed || us_socket_is_shut_down(0, s)) {
387391
us_poll_change(&s->p, loop, us_poll_events(&s->p) & LIBUS_SOCKET_READABLE);
392+
} else {
393+
#ifdef LIBUS_USE_KQUEUE
394+
/* Kqueue one-shot writable needs to be re-enabled */
395+
us_poll_change(&s->p, loop, us_poll_events(&s->p) | LIBUS_SOCKET_WRITABLE);
396+
#endif
388397
}
389398
}
390399

0 commit comments

Comments
 (0)