]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: stream-int: make si_idle_conn() only accept valid connections
authorWilly Tarreau <w@1wt.eu>
Wed, 5 Aug 2015 09:08:30 +0000 (11:08 +0200)
committerWilly Tarreau <w@1wt.eu>
Thu, 6 Aug 2015 09:11:10 +0000 (11:11 +0200)
This function is now dedicated to idle connections only, which means
that it must not be used without any endpoint nor anything not a
connection. The connection remains attached to the stream interface.

include/proto/stream_interface.h
src/proto_http.c

index 09c2a4e5e13a8335211d95e6742ea9bbe7eb5217..8c7a950766d5fa21176717e79fd68d4a67e45f5d 100644 (file)
@@ -167,17 +167,15 @@ static inline void si_release_endpoint(struct stream_interface *si)
        si_detach_endpoint(si);
 }
 
-/* Turn a possibly existing connection endpoint of stream interface <si> to
- * idle mode, which means that the connection will be polled for incoming events
- * and might be killed by the underlying I/O handler. If <pool> is not null, the
- * connection will also be added at the head of this list.
+/* Turn an existing connection endpoint of stream interface <si> to idle mode,
+ * which means that the connection will be polled for incoming events and might
+ * be killed by the underlying I/O handler. If <pool> is not null, the
+ * connection will also be added at the head of this list. This connection
+ * remains assigned to the stream interface it is currently attached to.
  */
 static inline void si_idle_conn(struct stream_interface *si, struct list *pool)
 {
-       struct connection *conn = objt_conn(si->end);
-
-       if (!conn)
-               return;
+       struct connection *conn = __objt_conn(si->end);
 
        if (pool)
                LIST_ADD(pool, &conn->list);
index 352dd75b08f07d979b7ab39b3acf2a1d39143655..d1acf30a9aa6e02e8792cdb3325ca85b13860cb7 100644 (file)
@@ -5186,11 +5186,10 @@ void http_end_txn_clean_session(struct stream *s)
        channel_auto_close(&s->res);
 
        /* we're in keep-alive with an idle connection, monitor it */
-       srv = NULL;
-       if (srv_conn)
+       if (srv_conn) {
                srv = objt_server(srv_conn->target);
-
-       si_idle_conn(&s->si[1], srv ? &srv->priv_conns : NULL);
+               si_idle_conn(&s->si[1], srv ? &srv->priv_conns : NULL);
+       }
 
        s->req.analysers = strm_li(s)->analysers;
        s->res.analysers = 0;