]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
OPTIM: splice: detect shutdowns and avoid splice() == 0
authorWilly Tarreau <w@1wt.eu>
Mon, 7 Jan 2013 15:38:26 +0000 (16:38 +0100)
committerWilly Tarreau <w@1wt.eu>
Mon, 7 Jan 2013 15:39:51 +0000 (16:39 +0100)
Since last commit introducing EPOLLRDHUP, the splicing code is able to
detect an incoming shutdown without calling splice() == 0. This avoids
one useless syscall.

src/raw_sock.c

index 20a867add07c9beca317c96ef7ae56386b362524..952891133deda4d003f4117106e9347ee4a1df66 100644 (file)
@@ -148,6 +148,10 @@ int raw_sock_to_pipe(struct connection *conn, struct pipe *pipe, unsigned int co
                retval += ret;
                pipe->data += ret;
 
+               /* if a POLL_HUP was present, we've read the last segment */
+               if ((fdtab[conn->t.sock.fd].ev & (FD_POLL_ERR|FD_POLL_HUP)) == FD_POLL_HUP)
+                       goto out_read0;
+
                if (pipe->data >= SPLICE_FULL_HINT || ret >= global.tune.recv_enough) {
                        /* We've read enough of it for this time, let's stop before
                         * being asked to poll.