MEDIUM: connection: centralize handling of nolinger in fd management

Right now we see many places doing their own setsockopt(SO_LINGER).
Better only do it just before the close() in fd_delete(). For this
we add a new flag on the file descriptor, indicating if it's safe or
not to linger. If not (eg: after a connect()), then the setsockopt()
call is automatically performed before a close().

The flag automatically turns to safe when receiving a read0.
diff --git a/include/proto/connection.h b/include/proto/connection.h
index a36906d..be9d712 100644
--- a/include/proto/connection.h
+++ b/include/proto/connection.h
@@ -434,6 +434,11 @@
 {
 	c->flags |= CO_FL_SOCK_RD_SH;
 	__conn_sock_stop_recv(c);
+	/* we don't risk keeping ports unusable if we found the
+	 * zero from the other side.
+	 */
+	if (c->flags & CO_FL_CTRL_READY)
+		fdtab[c->t.sock.fd].linger_risk = 0;
 }
 
 static inline void conn_data_read0(struct connection *c)
diff --git a/include/proto/fd.h b/include/proto/fd.h
index 3b1365d..7fe616e 100644
--- a/include/proto/fd.h
+++ b/include/proto/fd.h
@@ -226,6 +226,7 @@
 {
 	fdtab[fd].ev = 0;
 	fdtab[fd].new = 1;
+	fdtab[fd].linger_risk = 0;
 	if (fd + 1 > maxfd)
 		maxfd = fd + 1;
 }
diff --git a/include/types/fd.h b/include/types/fd.h
index 56a8c5c..701edfc 100644
--- a/include/types/fd.h
+++ b/include/types/fd.h
@@ -74,6 +74,7 @@
 	unsigned char ev;                    /* event seen in return of poll() : FD_POLL_* */
 	unsigned char new:1;                 /* 1 if this fd has just been created */
 	unsigned char updated:1;             /* 1 if this fd is already in the update list */
+	unsigned char linger_risk:1;         /* 1 if we must kill lingering before closing */
 };
 
 /* less often used information */