]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MEDIUM: frontend: don't restrict frontend_accept() to connections anymore
authorWilly Tarreau <w@1wt.eu>
Sun, 5 Apr 2015 16:01:06 +0000 (18:01 +0200)
committerWilly Tarreau <w@1wt.eu>
Mon, 6 Apr 2015 09:37:35 +0000 (11:37 +0200)
Now it can also initialize streams initiated by applets. This will be
needed for HTTP/2.

src/frontend.c
src/stream.c

index bb4383b2dd8c1aa548213a8115984d79fd483753..723ec41449d2a3b7231517f688fe40e9489f5bab 100644 (file)
 
 /* 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
- * disabled, a positive or null value in case of success. It only supports
- * streams with a connection in si[0].
+ * disabled, a positive or null value in case of success.
  */
 int frontend_accept(struct stream *s)
 {
        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 proxy *fe = sess->fe;
 
-       int cfd = conn->t.sock.fd;
-
        if (unlikely(fe->nb_req_cap > 0)) {
                if ((s->req_cap = pool_alloc2(fe->req_cap_pool)) == NULL)
                        goto out_return;        /* no memory */
@@ -92,7 +89,7 @@ int frontend_accept(struct stream *s)
                                if (!(s->logs.logwait &= ~(LW_CLIP|LW_INIT)))
                                        s->do_log(s);
                }
-               else {
+               else if (conn) {
                        char pn[INET6_ADDRSTRLEN], sn[INET6_ADDRSTRLEN];
 
                        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];
 
                conn_get_from_addr(conn);
@@ -126,13 +124,13 @@ int frontend_accept(struct stream *s)
                case AF_INET:
                case AF_INET6:
                        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));
                        break;
                case AF_UNIX:
                        /* UNIX socket, only the destination is known */
                        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);
                        break;
                }
index 5a021aac4540840162e09aceb62af8b9b90f7ef7..59d1d5de3c3148fd78d1fb172a4160024c88383e 100644 (file)
@@ -222,7 +222,7 @@ struct stream *stream_new(struct session *sess, struct task *t)
        else if (appctx)
                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;
 
        if (conn) {