From ef8a719f7070fb5f1cc634dcb64be250a947046f Mon Sep 17 00:00:00 2001
From: Willy Tarreau <w@1wt.eu>
Date: Fri, 23 Nov 2012 09:05:05 +0100
Subject: [PATCH] BUG/MINOR: checks: don't mark the FD as closed before
 transport close

Some future transport layers might need the connection's file descriptor
on ->close(), so we must not destroy it before we're finished with it.
---
 src/checks.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/checks.c b/src/checks.c
index a2a7a35d3..d38823b0b 100644
--- a/src/checks.c
+++ b/src/checks.c
@@ -1430,10 +1430,10 @@ static struct task *process_chk(struct task *t)
 
 				set_server_up(s);
 			}
-			conn->t.sock.fd = -1; /* no check running anymore */
 			conn_xprt_close(conn);
 			if (conn->ctrl)
 				fd_delete(fd);
+			conn->t.sock.fd = -1; /* no check running anymore */
 
 			rv = 0;
 			if (global.spread_checks > 0) {
@@ -1462,10 +1462,10 @@ static struct task *process_chk(struct task *t)
 			}
 			else
 				set_server_down(s);
-			conn->t.sock.fd = -1;
 			conn_xprt_close(conn);
 			if (conn->ctrl)
 				fd_delete(fd);
+			conn->t.sock.fd = -1;
 
 			rv = 0;
 			if (global.spread_checks > 0) {