/* flags below are used for connection handshakes */
CO_FL_SI_SEND_PROXY = 0x00000004, /* send a valid PROXY protocol header */
CO_FL_NOTIFY_SI = 0x00000008, /* notify stream interface about changes */
+ CO_FL_CONNECTED = 0x00000010, /* the connection is now established */
};
/* This structure describes a connection with its methods and data.
if (conn->flags & CO_FL_NOTIFY_SI)
stream_sock_update_conn(conn);
+ /* Last check, verify if the connection just established */
+ if (!(conn->flags & (CO_FL_WAIT_L4_CONN | CO_FL_CONNECTED)))
+ conn->flags |= CO_FL_CONNECTED;
+
/* remove the events before leaving */
fdtab[fd].ev &= ~(FD_POLL_IN | FD_POLL_OUT | FD_POLL_HUP | FD_POLL_ERR);
return ret;
int tcp_connect_probe(struct connection *conn)
{
int fd = conn->t.sock.fd;
- struct stream_interface *si = container_of(conn, struct stream_interface, conn);
- struct buffer *b = si->ob;
int retval = 0;
if (conn->flags & CO_FL_ERROR)
if ((fdtab[fd].ev & (FD_POLL_IN|FD_POLL_HUP)) == FD_POLL_HUP)
goto out_error;
- /* we might have been called just after an asynchronous shutw */
- if (b->flags & BF_SHUTW)
- goto out_wakeup;
-
/* We have no data to send to check the connection, and
* getsockopt() will not inform us whether the connection
* is still pending. So we'll reuse connect() to check the
/* otherwise we're connected */
}
- /* OK we just need to indicate that we got a connection
- * and that we wrote nothing.
- */
- b->flags |= BF_WRITE_NULL;
-
/* The FD is ready now, we'll mark the connection as complete and
* forward the event to the data layer which will update the stream
* interface flags.
*/
conn->flags &= ~CO_FL_WAIT_L4_CONN;
- si->exp = TICK_ETERNITY;
out_wakeup:
out_ignore:
if (conn->flags & CO_FL_ERROR)
si->flags |= SI_FL_ERR;
+ /* check for recent connection establishment */
+ if (!(conn->flags & (CO_FL_WAIT_L4_CONN | CO_FL_CONNECTED))) {
+ si->exp = TICK_ETERNITY;
+ si->ob->flags |= BF_WRITE_NULL;
+ }
+
/* process consumer side, only once if possible */
if (fdtab[fd].ev & (FD_POLL_OUT | FD_POLL_ERR)) {
if (si->ob->flags & BF_OUT_EMPTY) {