mirror of
http://git.haproxy.org/git/haproxy.git/
synced 2025-04-11 03:31:36 +00:00
MEDIUM: peers: initialize the task before the stream
Thanks to this we should be able to make use of stream_accept_session() now.
This commit is contained in:
parent
4099a7c273
commit
8baf906366
30
src/peers.c
30
src/peers.c
@ -1134,30 +1134,28 @@ static struct stream *peer_session_create(struct peer *peer, struct peer_session
|
|||||||
goto out_free_appctx;
|
goto out_free_appctx;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((s = pool_alloc2(pool2_stream)) == NULL) { /* disable this proxy for a while */
|
if ((t = task_new()) == NULL) {
|
||||||
Alert("out of memory in peer_session_create().\n");
|
Alert("out of memory in peer_session_create().\n");
|
||||||
goto out_free_sess;
|
goto out_free_sess;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
t->process = l->handler;
|
||||||
|
t->context = sess;
|
||||||
|
t->nice = l->nice;
|
||||||
|
|
||||||
|
if ((s = pool_alloc2(pool2_stream)) == NULL) { /* disable this proxy for a while */
|
||||||
|
Alert("out of memory in peer_session_create().\n");
|
||||||
|
goto out_free_task;
|
||||||
|
}
|
||||||
|
|
||||||
LIST_ADDQ(&streams, &s->list);
|
LIST_ADDQ(&streams, &s->list);
|
||||||
LIST_INIT(&s->back_refs);
|
LIST_INIT(&s->back_refs);
|
||||||
LIST_INIT(&s->buffer_wait);
|
LIST_INIT(&s->buffer_wait);
|
||||||
|
|
||||||
s->flags = SF_ASSIGNED|SF_ADDR_SET;
|
s->flags = SF_ASSIGNED|SF_ADDR_SET;
|
||||||
|
|
||||||
/* if this session comes from a known monitoring system, we want to ignore
|
|
||||||
* it as soon as possible, which means closing it immediately for TCP.
|
|
||||||
*/
|
|
||||||
if ((t = task_new()) == NULL) { /* disable this proxy for a while */
|
|
||||||
Alert("out of memory in peer_session_create().\n");
|
|
||||||
goto out_free_strm;
|
|
||||||
}
|
|
||||||
|
|
||||||
t->process = l->handler;
|
|
||||||
t->context = s;
|
|
||||||
t->nice = l->nice;
|
|
||||||
|
|
||||||
s->task = t;
|
s->task = t;
|
||||||
|
t->context = s;
|
||||||
s->sess = sess;
|
s->sess = sess;
|
||||||
s->be = s->sess->fe;
|
s->be = s->sess->fe;
|
||||||
s->req.buf = s->res.buf = NULL;
|
s->req.buf = s->res.buf = NULL;
|
||||||
@ -1189,7 +1187,7 @@ static struct stream *peer_session_create(struct peer *peer, struct peer_session
|
|||||||
* pre-initialized connection in si->conn.
|
* pre-initialized connection in si->conn.
|
||||||
*/
|
*/
|
||||||
if (unlikely((conn = conn_new()) == NULL))
|
if (unlikely((conn = conn_new()) == NULL))
|
||||||
goto out_free_task;
|
goto out_free_strm;
|
||||||
|
|
||||||
conn_prepare(conn, peer->proto, peer->xprt);
|
conn_prepare(conn, peer->proto, peer->xprt);
|
||||||
si_attach_conn(&s->si[1], conn);
|
si_attach_conn(&s->si[1], conn);
|
||||||
@ -1270,11 +1268,11 @@ static struct stream *peer_session_create(struct peer *peer, struct peer_session
|
|||||||
return s;
|
return s;
|
||||||
|
|
||||||
/* Error unrolling */
|
/* Error unrolling */
|
||||||
out_free_task:
|
|
||||||
task_free(t);
|
|
||||||
out_free_strm:
|
out_free_strm:
|
||||||
LIST_DEL(&s->list);
|
LIST_DEL(&s->list);
|
||||||
pool_free2(pool2_stream, s);
|
pool_free2(pool2_stream, s);
|
||||||
|
out_free_task:
|
||||||
|
task_free(t);
|
||||||
out_free_sess:
|
out_free_sess:
|
||||||
session_free(sess);
|
session_free(sess);
|
||||||
out_free_appctx:
|
out_free_appctx:
|
||||||
|
Loading…
Reference in New Issue
Block a user