]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
[MINOR] stream_sock: enable MSG_MORE when forwarding finite amount of data
authorWilly Tarreau <w@1wt.eu>
Sun, 3 Jan 2010 10:18:34 +0000 (11:18 +0100)
committerWilly Tarreau <w@1wt.eu>
Sun, 3 Jan 2010 10:18:34 +0000 (11:18 +0100)
While it could be dangerous to enable MSG_MORE on infinite data (eg:
interactive sessions), it makes sense to enable it when we know the
chunk to be sent is just a part of a larger one.

src/stream_sock.c

index a9bf47aeef8988d55bcc4164753c2abf0de659a0..7e9dd2c2fca6a61bda3b220aaa280d7003ef93a7 100644 (file)
@@ -603,6 +603,7 @@ static int stream_sock_write_loop(struct stream_interface *si, struct buffer *b)
                 *    the ongoing FIN with the last segment.
                 *  - we know we can't send everything at once and must get back
                 *    here because of unaligned data
+                *  - there is still a finite amount of data to forward
                 * The test is arranged so that the most common case does only 2
                 * tests.
                 */
@@ -611,8 +612,8 @@ static int stream_sock_write_loop(struct stream_interface *si, struct buffer *b)
                        unsigned int send_flag = MSG_DONTWAIT | MSG_NOSIGNAL;
 
                        if (MSG_MORE &&
-                           (((b->flags & (BF_SHUTW|BF_SHUTW_NOW|BF_HIJACK)) == BF_SHUTW_NOW &&
-                             (max == b->send_max)) ||
+                           ((b->to_forward && b->to_forward != BUF_INFINITE_FORWARD) ||
+                            ((b->flags & (BF_SHUTW|BF_SHUTW_NOW|BF_HIJACK)) == BF_SHUTW_NOW && (max == b->send_max)) ||
                             (max != b->l && max != b->send_max))
                            && (fdtab[si->fd].flags & FD_FL_TCP)) {
                                send_flag |= MSG_MORE;