commit 12e30ce560c2b79f2de9ab7f44626063c0e7e2ff
Author: Oswald Buddenhagen <[email protected]>
Date: Mon Jul 29 12:05:43 2024 +0200
cap readsz at buffer size
otherwise we may get negative comparison sizes, which the unsigned
arithmetic we use cannot represent. this would prevent buffer content
downshifting, resulting in prepare_read() erroring out.
amends 859b7dd.
REFMAIL: [email protected]
REFMAIL: [email protected]
REFMAIL: [email protected]
REFMAIL: [email protected]
src/socket.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/src/socket.c b/src/socket.c
index 52cd7c2..afd3f18 100644
--- a/src/socket.c
+++ b/src/socket.c
@@ -908,8 +908,11 @@ socket_fill( conn_t *sock )
// IIR filter for tracking average size of bulk reads.
// We use this to optimize the free space at the end of the
// buffer, hence the factor of 1.5.
- if (n >= MIN_BULK_READ)
+ if (n >= MIN_BULK_READ) {
sock->readsz = (sock->readsz * 3 + n * 3 / 2) / 4;
+ if (sock->readsz > sizeof(sock->buf))
+ sock->readsz = sizeof(sock->buf);
+ }
socket_filled( sock, (uint)n );
}
_______________________________________________
isync-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/isync-devel