From 808fc3a604300395d205b948325baac44e342a6d Mon Sep 17 00:00:00 2001 From: stefan11111 Date: Wed, 6 Aug 2025 23:22:35 +0300 Subject: [PATCH] os: further simplify FlushClient Since FlushClient only writes the data in the client's buffer, with no extra data or padding, we only write at most as many bytes as there are in the client buffer. we just have to set oco->count to notWritten, the amount we still have to write. Signed-off-by: stefan11111 --- os/io.c | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/os/io.c b/os/io.c index fb71d2864b..5c57c7429f 100644 --- a/os/io.c +++ b/os/io.c @@ -631,7 +631,7 @@ FlushAllOutput(void) continue; if (!client_is_ready(client)) { oc = (OsCommPtr) client->osPrivate; - (void) FlushClient(client, oc); + FlushClient(client, oc); } else NewOutputPending = TRUE; } @@ -932,19 +932,14 @@ FlushClient(ClientPtr who, OsCommPtr oc) the rest. */ output_pending_mark(who); - if (written < oco->count) { - if (written > 0) { - oco->count -= written; - memmove((char *) oco->buf, - (char *) oco->buf + written, oco->count); - written = 0; - } - } - else { - written -= oco->count; - oco->count = 0; + if (written > 0) { + oco->count -= written; + memmove((char *) oco->buf, + (char *) oco->buf + written, oco->count); + written = 0; } + oco->count = notWritten; ospoll_listen(server_poll, oc->fd, X_NOTIFY_WRITE); /* return only the amount explicitly requested */