MEDIUM: connection: it's not the data layer's role to validate the connection

Till now we used to perform the L4_CONN check in the data layer
(eg: stream interface) but that does not make sense, because some transport
layers will imply that the connection is opened (eg: SSL), and also because
the complexity to check for this is higher in the data layer than in the
transport layer. This is so much true that some read0 cases did not validate
the connection.

So as of now, the transport layer is responsible for clearing L4_CONN when
it detects an activity, and the data layer may safely rely on this flag. This
only impacts a minor change in raw_sock and stream_interface for now.
This commit is contained in:
Willy Tarreau 2012-10-04 20:20:46 +02:00
parent 78eaebed13
commit 665e6ee7aa
2 changed files with 11 additions and 6 deletions

View File

@ -156,10 +156,13 @@ int raw_sock_to_pipe(struct connection *conn, struct pipe *pipe, unsigned int co
}
} /* while */
if (unlikely(conn->flags & CO_FL_WAIT_L4_CONN) && retval)
conn->flags &= ~CO_FL_WAIT_L4_CONN;
return retval;
out_read0:
conn_sock_read0(conn);
conn->flags &= ~CO_FL_WAIT_L4_CONN;
return retval;
}
@ -190,6 +193,8 @@ int raw_sock_from_pipe(struct connection *conn, struct pipe *pipe)
done += ret;
pipe->data -= ret;
}
if (unlikely(conn->flags & CO_FL_WAIT_L4_CONN) && done)
conn->flags &= ~CO_FL_WAIT_L4_CONN;
return done;
}
@ -269,10 +274,14 @@ static int raw_sock_to_buf(struct connection *conn, struct buffer *buf, int coun
break;
}
}
if (unlikely(conn->flags & CO_FL_WAIT_L4_CONN) && done)
conn->flags &= ~CO_FL_WAIT_L4_CONN;
return done;
read0:
conn_sock_read0(conn);
conn->flags &= ~CO_FL_WAIT_L4_CONN;
return done;
}
@ -330,6 +339,8 @@ static int raw_sock_from_buf(struct connection *conn, struct buffer *buf, int fl
break;
}
}
if (unlikely(conn->flags & CO_FL_WAIT_L4_CONN) && done)
conn->flags &= ~CO_FL_WAIT_L4_CONN;
return done;
}

View File

@ -721,9 +721,6 @@ static int si_conn_send_loop(struct connection *conn)
if (ret <= 0)
break;
if (si->conn.flags & CO_FL_WAIT_L4_CONN)
si->conn.flags &= ~CO_FL_WAIT_L4_CONN;
b->flags |= CF_WRITE_PARTIAL;
if (!b->buf.o) {
@ -1049,9 +1046,6 @@ static void si_conn_recv_cb(struct connection *conn)
b_adv(&b->buf, fwd);
}
if (conn->flags & CO_FL_WAIT_L4_CONN)
conn->flags &= ~CO_FL_WAIT_L4_CONN;
b->flags |= CF_READ_PARTIAL;
b->total += ret;