From 1ea3f10cd0d8668ff1f19fc397f78a7929648403 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Ondr=C3=A1=C4=8Dek?= Date: Wed, 6 Nov 2024 18:26:14 +0100 Subject: [PATCH] daemon/io: keep TCP data in system queue on buffer overflow --- daemon/io.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/daemon/io.c b/daemon/io.c index 366489075..98500c347 100644 --- a/daemon/io.c +++ b/daemon/io.c @@ -324,6 +324,20 @@ static void tcp_recv(uv_stream_t *handle, ssize_t nread, const uv_buf_t *buf) return; } + if (nread == UV_ENOBUFS) { + /* No space available in session buffer. + * The connection may be just waiting in defer. + * Ignore the error and keep the data in system queue for later reading or timeout. */ + if (kr_log_is_debug(IO, NULL)) { + struct sockaddr *peer = session2_get_peer(s); + char *peer_str = kr_straddr(peer); + kr_log_debug(IO, "=> incoming data from '%s' waiting (%s)\n", + peer_str ? peer_str : "", + uv_strerror(nread)); + } + return; + } + if (nread < 0 || !buf->base) { if (kr_log_is_debug(IO, NULL)) { struct sockaddr *peer = session2_get_peer(s);