]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MEDIUM: tcp: report in tcp_drain() that lingering is already disabled on close
authorWilly Tarreau <w@1wt.eu>
Mon, 20 Jan 2014 10:56:37 +0000 (11:56 +0100)
committerWilly Tarreau <w@1wt.eu>
Mon, 20 Jan 2014 21:27:17 +0000 (22:27 +0100)
When an incoming shutdown or error is detected, we know that we
can safely close without disabling lingering. Do it in tcp_drain()
so that we don't have to do it from each and every caller.

src/proto_tcp.c

index c02409d7205b69c418ad8eafe4557ef621a2586d..d01be31bd93054d4f1fa57a9b4d56645c3351a71 100644 (file)
@@ -541,8 +541,11 @@ int tcp_drain(int fd)
 #endif
                        len = recv(fd, trash.str, trash.size, MSG_DONTWAIT | MSG_NOSIGNAL);
 
-               if (len == 0)                /* cool, shutdown received */
+               if (len == 0) {
+                       /* cool, shutdown received */
+                       fdtab[fd].linger_risk = 0;
                        return 1;
+               }
 
                if (len < 0) {
                        if (errno == EAGAIN) /* connection not closed yet */
@@ -550,6 +553,7 @@ int tcp_drain(int fd)
                        if (errno == EINTR)  /* oops, try again */
                                continue;
                        /* other errors indicate a dead connection, fine. */
+                       fdtab[fd].linger_risk = 0;
                        return 1;
                }
                /* OK we read some data, let's try again once */
@@ -635,7 +639,7 @@ int tcp_connect_probe(struct connection *conn)
        /* Write error on the file descriptor. Report it to the connection
         * and disable polling on this FD.
         */
-
+       fdtab[fd].linger_risk = 0;
        conn->flags |= CO_FL_ERROR | CO_FL_SOCK_RD_SH | CO_FL_SOCK_WR_SH;
        __conn_sock_stop_both(conn);
        return 0;