mirror of
http://git.haproxy.org/git/haproxy.git/
synced 2025-04-22 23:15:37 +00:00
MEDIUM: frontend: don't restrict frontend_accept() to connections anymore
Now it can also initialize streams initiated by applets. This will be needed for HTTP/2.
This commit is contained in:
parent
f9d1bc6d9a
commit
e0232f1e33
@ -48,18 +48,15 @@
|
|||||||
|
|
||||||
/* Finish a stream accept() for a proxy (TCP or HTTP). It returns a negative
|
/* Finish a stream accept() for a proxy (TCP or HTTP). It returns a negative
|
||||||
* value in case of a critical failure which must cause the listener to be
|
* value in case of a critical failure which must cause the listener to be
|
||||||
* disabled, a positive or null value in case of success. It only supports
|
* disabled, a positive or null value in case of success.
|
||||||
* streams with a connection in si[0].
|
|
||||||
*/
|
*/
|
||||||
int frontend_accept(struct stream *s)
|
int frontend_accept(struct stream *s)
|
||||||
{
|
{
|
||||||
struct session *sess = s->sess;
|
struct session *sess = s->sess;
|
||||||
struct connection *conn = __objt_conn(sess->origin);
|
struct connection *conn = objt_conn(sess->origin);
|
||||||
struct listener *l = sess->listener;
|
struct listener *l = sess->listener;
|
||||||
struct proxy *fe = sess->fe;
|
struct proxy *fe = sess->fe;
|
||||||
|
|
||||||
int cfd = conn->t.sock.fd;
|
|
||||||
|
|
||||||
if (unlikely(fe->nb_req_cap > 0)) {
|
if (unlikely(fe->nb_req_cap > 0)) {
|
||||||
if ((s->req_cap = pool_alloc2(fe->req_cap_pool)) == NULL)
|
if ((s->req_cap = pool_alloc2(fe->req_cap_pool)) == NULL)
|
||||||
goto out_return; /* no memory */
|
goto out_return; /* no memory */
|
||||||
@ -92,7 +89,7 @@ int frontend_accept(struct stream *s)
|
|||||||
if (!(s->logs.logwait &= ~(LW_CLIP|LW_INIT)))
|
if (!(s->logs.logwait &= ~(LW_CLIP|LW_INIT)))
|
||||||
s->do_log(s);
|
s->do_log(s);
|
||||||
}
|
}
|
||||||
else {
|
else if (conn) {
|
||||||
char pn[INET6_ADDRSTRLEN], sn[INET6_ADDRSTRLEN];
|
char pn[INET6_ADDRSTRLEN], sn[INET6_ADDRSTRLEN];
|
||||||
|
|
||||||
conn_get_from_addr(conn);
|
conn_get_from_addr(conn);
|
||||||
@ -117,7 +114,8 @@ int frontend_accept(struct stream *s)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (unlikely((global.mode & MODE_DEBUG) && (!(global.mode & MODE_QUIET) || (global.mode & MODE_VERBOSE)))) {
|
if (unlikely((global.mode & MODE_DEBUG) && conn &&
|
||||||
|
(!(global.mode & MODE_QUIET) || (global.mode & MODE_VERBOSE)))) {
|
||||||
char pn[INET6_ADDRSTRLEN];
|
char pn[INET6_ADDRSTRLEN];
|
||||||
|
|
||||||
conn_get_from_addr(conn);
|
conn_get_from_addr(conn);
|
||||||
@ -126,13 +124,13 @@ int frontend_accept(struct stream *s)
|
|||||||
case AF_INET:
|
case AF_INET:
|
||||||
case AF_INET6:
|
case AF_INET6:
|
||||||
chunk_printf(&trash, "%08x:%s.accept(%04x)=%04x from [%s:%d]\n",
|
chunk_printf(&trash, "%08x:%s.accept(%04x)=%04x from [%s:%d]\n",
|
||||||
s->uniq_id, fe->id, (unsigned short)l->fd, (unsigned short)cfd,
|
s->uniq_id, fe->id, (unsigned short)l->fd, (unsigned short)conn->t.sock.fd,
|
||||||
pn, get_host_port(&conn->addr.from));
|
pn, get_host_port(&conn->addr.from));
|
||||||
break;
|
break;
|
||||||
case AF_UNIX:
|
case AF_UNIX:
|
||||||
/* UNIX socket, only the destination is known */
|
/* UNIX socket, only the destination is known */
|
||||||
chunk_printf(&trash, "%08x:%s.accept(%04x)=%04x from [unix:%d]\n",
|
chunk_printf(&trash, "%08x:%s.accept(%04x)=%04x from [unix:%d]\n",
|
||||||
s->uniq_id, fe->id, (unsigned short)l->fd, (unsigned short)cfd,
|
s->uniq_id, fe->id, (unsigned short)l->fd, (unsigned short)conn->t.sock.fd,
|
||||||
l->luid);
|
l->luid);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -222,7 +222,7 @@ struct stream *stream_new(struct session *sess, struct task *t)
|
|||||||
else if (appctx)
|
else if (appctx)
|
||||||
s->si[0].flags |= SI_FL_WAIT_DATA;
|
s->si[0].flags |= SI_FL_WAIT_DATA;
|
||||||
|
|
||||||
if (conn && p->accept && p->accept(s) < 0)
|
if (p->accept && p->accept(s) < 0)
|
||||||
goto out_fail_accept;
|
goto out_fail_accept;
|
||||||
|
|
||||||
if (conn) {
|
if (conn) {
|
||||||
|
Loading…
Reference in New Issue
Block a user