]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: connection: introduce a new receive flag: CO_RFL_READ_ONCE
authorWilly Tarreau <w@1wt.eu>
Thu, 20 Feb 2020 10:04:40 +0000 (11:04 +0100)
committerWilly Tarreau <w@1wt.eu>
Fri, 21 Feb 2020 10:22:45 +0000 (11:22 +0100)
This flag is currently supported by raw_sock to perform a single recv()
attempt and avoid subscribing. Typically on the request and response
paths with keep-alive, with short messages we know that it's very likely
that the first message is enough.

include/types/connection.h
src/raw_sock.c

index 52c7c7e3c1211a968c9cc7f679ef96ac363565f7..bfd6547ee7ac41cde86fb953a4dacedee24d8bab 100644 (file)
@@ -284,6 +284,7 @@ enum {
 enum {
        CO_RFL_BUF_WET     = 0x0001,    /* Buffer still has some output data present */
        CO_RFL_BUF_FLUSH   = 0x0002,    /* Flush mux's buffers but don't read more data */
+       CO_RFL_READ_ONCE   = 0x0004,    /* don't loop even if the request/response is small */
 };
 
 /* flags that can be passed to xprt->snd_buf() and mux->snd_buf() */
index 06d5f4d9ea3f06b2692dc3ec4f11963cb0125444..ab03a8fd69b2432126866b05d27735d360be8b3c 100644 (file)
@@ -292,6 +292,9 @@ static size_t raw_sock_to_buf(struct connection *conn, void *xprt_ctx, struct bu
                                }
                        }
                        count -= ret;
+
+                       if (flags & CO_RFL_READ_ONCE)
+                               break;
                }
                else if (ret == 0) {
                        goto read0;