mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-09-26 00:01:45 +02:00
MEDIUM: stream: isolate connection-specific initialization code
In stream_accept_session(), we perform some operations that explicitly want a connection as the origin, but we'll soon have other types of origin (eg: applet). Thus change the test to ensure we only call this code with connections. Additionally, we refrain from calling fe->accept() if the origin is not a connection, because for now the only fe->accept() may only use a connection (frontend_accept).
This commit is contained in:
parent
ce7eec9186
commit
f2b9874bcf
25
src/stream.c
25
src/stream.c
@ -69,7 +69,7 @@ int stream_accept_session(struct session *sess, struct task *t)
|
|||||||
struct stream *s;
|
struct stream *s;
|
||||||
struct listener *l = sess->listener;
|
struct listener *l = sess->listener;
|
||||||
struct proxy *p = sess->fe;
|
struct proxy *p = sess->fe;
|
||||||
struct connection *conn = __objt_conn(sess->origin);
|
struct connection *conn = objt_conn(sess->origin);
|
||||||
int ret;
|
int ret;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
@ -151,7 +151,8 @@ int stream_accept_session(struct session *sess, struct task *t)
|
|||||||
si_set_state(&s->si[0], SI_ST_EST);
|
si_set_state(&s->si[0], SI_ST_EST);
|
||||||
|
|
||||||
/* attach the incoming connection to the stream interface now. */
|
/* attach the incoming connection to the stream interface now. */
|
||||||
si_attach_conn(&s->si[0], conn);
|
if (conn)
|
||||||
|
si_attach_conn(&s->si[0], conn);
|
||||||
|
|
||||||
if (likely(sess->fe->options2 & PR_O2_INDEPSTR))
|
if (likely(sess->fe->options2 & PR_O2_INDEPSTR))
|
||||||
s->si[0].flags |= SI_FL_INDEP_STR;
|
s->si[0].flags |= SI_FL_INDEP_STR;
|
||||||
@ -204,9 +205,13 @@ int stream_accept_session(struct session *sess, struct task *t)
|
|||||||
HLUA_INIT(&s->hlua);
|
HLUA_INIT(&s->hlua);
|
||||||
|
|
||||||
/* finish initialization of the accepted file descriptor */
|
/* finish initialization of the accepted file descriptor */
|
||||||
conn_data_want_recv(conn);
|
if (conn)
|
||||||
|
conn_data_want_recv(conn);
|
||||||
|
|
||||||
if (p->accept && (ret = p->accept(s)) <= 0) {
|
/* FIXME: we shouldn't restrict ourselves to connections but for now
|
||||||
|
* the only ->accept() only works with sessions.
|
||||||
|
*/
|
||||||
|
if (conn && p->accept && (ret = p->accept(s)) <= 0) {
|
||||||
/* Either we had an unrecoverable error (<0) or work is
|
/* Either we had an unrecoverable error (<0) or work is
|
||||||
* finished (=0, eg: monitoring), in both situations,
|
* finished (=0, eg: monitoring), in both situations,
|
||||||
* we can release everything and close.
|
* we can release everything and close.
|
||||||
@ -214,12 +219,14 @@ int stream_accept_session(struct session *sess, struct task *t)
|
|||||||
goto out_free_strm;
|
goto out_free_strm;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* if logs require transport layer information, note it on the connection */
|
if (conn) {
|
||||||
if (s->logs.logwait & LW_XPRT)
|
/* if logs require transport layer information, note it on the connection */
|
||||||
conn->flags |= CO_FL_XPRT_TRACKED;
|
if (s->logs.logwait & LW_XPRT)
|
||||||
|
conn->flags |= CO_FL_XPRT_TRACKED;
|
||||||
|
|
||||||
/* we want the connection handler to notify the stream interface about updates. */
|
/* we want the connection handler to notify the stream interface about updates. */
|
||||||
conn->flags |= CO_FL_WAKE_DATA;
|
conn->flags |= CO_FL_WAKE_DATA;
|
||||||
|
}
|
||||||
|
|
||||||
/* it is important not to call the wakeup function directly but to
|
/* it is important not to call the wakeup function directly but to
|
||||||
* pass through task_wakeup(), because this one knows how to apply
|
* pass through task_wakeup(), because this one knows how to apply
|
||||||
|
Loading…
x
Reference in New Issue
Block a user