]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MEDIUM: stream-int: simplify si_alloc_conn()
authorWilly Tarreau <w@1wt.eu>
Wed, 5 Aug 2015 19:47:23 +0000 (21:47 +0200)
committerWilly Tarreau <w@1wt.eu>
Wed, 5 Aug 2015 19:51:09 +0000 (21:51 +0200)
Since we now always call this function with the reuse parameter cleared,
let's simplify the function's logic as it cannot return the existing
connection anymore. The savings on this inline function are appreciable
(240 bytes) :

$ size haproxy.old haproxy.new
   text    data     bss     dec     hex filename
1020383   40816   36928 1098127  10c18f haproxy.old
1020143   40816   36928 1097887  10c09f haproxy.new

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

index dac4c0a19cb0b4809a655ebf65e115670d395188..449d5e6bc8ebb85ba1dd9493fb35d9b148204aa9 100644 (file)
@@ -271,27 +271,15 @@ static inline void si_applet_stop_get(struct stream_interface *si)
 }
 
 /* Try to allocate a new connection and assign it to the interface. If
- * a connection was previously allocated and the <reuse> flag is set,
- * it is returned unmodified. Otherwise it is reset.
+ * an endpoint was previously allocated, it is released first. The newly
+ * allocated connection is initialized, assigned to the stream interface,
+ * and returned.
  */
-/* Returns the stream interface's existing connection if one such already
- * exists, or tries to allocate and initialize a new one which is then
- * assigned to the stream interface.
- */
-static inline struct connection *si_alloc_conn(struct stream_interface *si, int reuse)
+static inline struct connection *si_alloc_conn(struct stream_interface *si)
 {
        struct connection *conn;
 
-       /* If we find a reusable connection, we return it, otherwise we start
-        * by releasing what we have (non-reusable conn or applet).
-        */
-       if (si->end) {
-               conn = objt_conn(si->end);
-               if (conn && reuse)
-                       return conn;
-
-               si_release_endpoint(si);
-       }
+       si_release_endpoint(si);
 
        conn = conn_new();
        if (conn)
index a1c700765d490f4296600e36b20d5f2b2f2ff7c4..f8185d7fefffca5621f6341b2c0eb0abf8a3c7e3 100644 (file)
@@ -1051,7 +1051,7 @@ int connect_server(struct stream *s)
        }
 
        if (!reuse)
-               srv_conn = si_alloc_conn(&s->si[1], 0);
+               srv_conn = si_alloc_conn(&s->si[1]);
 
        if (!srv_conn)
                return SF_ERR_RESOURCE;
index 6fe3797bc6555fbb5f788ad59c0b9495c44ae191..1c2938b856868e6476e7e84bf9d1825dbd51f966 100644 (file)
@@ -2062,7 +2062,7 @@ __LJMP static int hlua_socket_connect(struct lua_State *L)
        ip      = MAY_LJMP(luaL_checkstring(L, 2));
        port    = MAY_LJMP(luaL_checkinteger(L, 3));
 
-       conn = si_alloc_conn(&socket->s->si[1], 0);
+       conn = si_alloc_conn(&socket->s->si[1]);
        if (!conn)
                WILL_LJMP(luaL_error(L, "connect: internal error"));
 
index 18a9455c972a24504d7599df7fde734ab3424106..161939a374b5f4dc7513f75545c6cd75f6885551 100644 (file)
@@ -4477,7 +4477,7 @@ int http_process_request(struct stream *s, struct channel *req, int an_bit)
                char *path;
 
                /* Note that for now we don't reuse existing proxy connections */
-               if (unlikely((conn = si_alloc_conn(&s->si[1], 0)) == NULL)) {
+               if (unlikely((conn = si_alloc_conn(&s->si[1])) == NULL)) {
                        txn->req.msg_state = HTTP_MSG_ERROR;
                        txn->status = 500;
                        req->analysers = 0;