]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MEDIUM: connection: always unset the transport layer upon close
authorWilly Tarreau <w@1wt.eu>
Fri, 12 Oct 2012 15:00:05 +0000 (17:00 +0200)
committerWilly Tarreau <w@1wt.eu>
Fri, 12 Oct 2012 15:03:04 +0000 (17:03 +0200)
When calling conn_xprt_close(), we always clear the transport pointer
so that all transport layers leave the connection in the same state after
a close. This will also make it safer and cheaper to call conn_xprt_close()
multiple times if needed.

include/proto/connection.h

index 37af379680215a43607a06c8fc9ea470cfdf5ff6..ff63e03ccad40407d4cb1e125cdf007eef8fb428 100644 (file)
@@ -45,11 +45,16 @@ static inline int conn_xprt_init(struct connection *conn)
        return 0;
 }
 
-/* Calls the close() function of the transport layer if any */
+/* Calls the close() function of the transport layer if any, and always unsets
+ * the transport layer.
+ */
 static inline void conn_xprt_close(struct connection *conn)
 {
-       if (conn->xprt && conn->xprt->close)
-               conn->xprt->close(conn);
+       if (conn->xprt) {
+               if (conn->xprt->close)
+                       conn->xprt->close(conn);
+               conn->xprt = NULL;
+       }
 }
 
 /* Update polling on connection <c>'s file descriptor depending on its current