@scriptc/runtime 0.0.24 → 0.0.25
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/scr_net.c +12 -5
package/package.json
CHANGED
package/src/scr_net.c
CHANGED
|
@@ -987,15 +987,21 @@ static bool scr_net_sock_deliver(ScrNetSocket *s, const char *buf, size_t n) {
|
|
|
987
987
|
return true;
|
|
988
988
|
}
|
|
989
989
|
|
|
990
|
-
/* One readable wake: read until EAGAIN/EOF, one 'data'
|
|
991
|
-
* chunk (Node's chunking is arrival-driven too — only the
|
|
992
|
-
* bytes are contractual, the stdin stance).
|
|
993
|
-
* the
|
|
994
|
-
*
|
|
990
|
+
/* One readable wake: read until EAGAIN/EOF OR a bounded batch, one 'data'
|
|
991
|
+
* emit per read(2) chunk (Node's chunking is arrival-driven too — only the
|
|
992
|
+
* reassembled bytes are contractual, the stdin stance). The batch bound is
|
|
993
|
+
* the loop's fairness fence: a continuously writing peer can otherwise keep
|
|
994
|
+
* every nonblocking read successful forever and strand timers plus every
|
|
995
|
+
* other fd inside this function. All poller arms are level-triggered, so
|
|
996
|
+
* unread kernel bytes make the socket ready again on the next loop turn.
|
|
997
|
+
* Peeked/unshifted bytes in the receive buffer deliver first — they precede
|
|
998
|
+
* the kernel's in the stream. A TLS socket drains those through the engine's
|
|
999
|
+
* bio instead. */
|
|
995
1000
|
static void scr_net_sock_append_rbuf(ScrNetSocket *s, const char *data, size_t len);
|
|
996
1001
|
static void scr_net_sock_transport_pump(ScrNetSocket *s);
|
|
997
1002
|
|
|
998
1003
|
static void scr_net_sock_read(ScrNetSocket *s) {
|
|
1004
|
+
size_t reads_left = 32; /* at most 2 MiB with the 64 KiB read buffer */
|
|
999
1005
|
if (s->tops && !s->t_est) return; /* readiness feeds the handshake pump instead */
|
|
1000
1006
|
for (;;) {
|
|
1001
1007
|
if (s->fd < 0 || s->user_paused) return;
|
|
@@ -1061,6 +1067,7 @@ static void scr_net_sock_read(ScrNetSocket *s) {
|
|
|
1061
1067
|
}
|
|
1062
1068
|
}
|
|
1063
1069
|
scr_net_sock_update_read(s); /* a once-listener may have been the last consumer */
|
|
1070
|
+
if (--reads_left == 0) return;
|
|
1064
1071
|
}
|
|
1065
1072
|
}
|
|
1066
1073
|
|