]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: connections: Get rid of txbuf.
authorOlivier Houchard <ohouchard@haproxy.com>
Thu, 16 Aug 2018 13:41:52 +0000 (15:41 +0200)
committerWilly Tarreau <w@1wt.eu>
Thu, 16 Aug 2018 15:29:51 +0000 (17:29 +0200)
Remove txbuf from conn_stream. It is not used yet, and its only user will
probably be the mux_h2, so it will be better suited in the struct h2s.

include/proto/connection.h
include/types/connection.h
src/checks.c
src/connection.c
src/stream_interface.c

index c677fb29a41c93845fefb7ff4f38548bdf29cb65..e4621ccbdef08668adbbc56139b72a72cc4a0591 100644 (file)
@@ -44,9 +44,6 @@ int init_connection();
  */
 void conn_fd_handler(int fd);
 
-/* conn_stream functions */
-size_t __cs_send(struct conn_stream *cs, struct buffer *buf, size_t count, int flags);
-
 /* receive a PROXY protocol header over a connection */
 int conn_recv_proxy(struct connection *conn, int flag);
 int make_proxy_line(char *buf, int buf_len, struct server *srv, struct connection *remote);
@@ -303,17 +300,6 @@ static inline void cs_update_mux_polling(struct conn_stream *cs)
                conn->mux->update_poll(cs);
 }
 
-/* conn_stream send function. Uses mux->snd_buf() if defined, otherwise
- * falls back to __cs_send().
- */
-static inline size_t cs_send(struct conn_stream *cs, struct buffer *buf, size_t count, int flags)
-{
-       if (cs->conn->mux->snd_buf)
-               return cs->conn->mux->snd_buf(cs, buf, count, flags);
-       else
-               return __cs_send(cs, buf, count, flags);
-}
-
 /***** Event manipulation primitives for use by DATA I/O callbacks *****/
 /* The __conn_* versions do not propagate to lower layers and are only meant
  * to be used by handlers called by the connection handler. The other ones
@@ -615,7 +601,6 @@ static inline void cs_init(struct conn_stream *cs, struct connection *conn)
        LIST_INIT(&cs->wait_list.list);
        LIST_INIT(&cs->send_wait_list);
        cs->conn = conn;
-       cs->txbuf = BUF_NULL;
 }
 
 /* Initializes all required fields for a new connection. Note that it does the
@@ -676,17 +661,6 @@ static inline struct connection *conn_new()
        return conn;
 }
 
-/* Releases the conn_stream's tx buf if it exists. The buffer is automatically
- * replaced with a pointer to the empty buffer.
- */
-static inline void cs_drop_txbuf(struct conn_stream *cs)
-{
-       if (b_size(&cs->txbuf)) {
-               b_free(&cs->txbuf);
-               offer_buffers(NULL, tasks_run_queue);
-       }
-}
-
 /* Releases a conn_stream previously allocated by cs_new(), as well as any
  * buffer it would still hold.
  */
@@ -695,7 +669,6 @@ static inline void cs_free(struct conn_stream *cs)
        if (cs->wait_list.task)
                tasklet_free(cs->wait_list.task);
 
-       cs_drop_txbuf(cs);
        pool_free(pool_head_connstream, cs);
 }
 
index f16b0cd94a9885da2301e22bd32a586e951dd09d..abe85a477f760a3fda5f1621100b1a4b36bbc760 100644 (file)
@@ -372,7 +372,6 @@ struct conn_stream {
        struct connection *conn;             /* xprt-level connection */
        struct wait_list wait_list;          /* We're in a wait list for send */
        struct list send_wait_list;          /* list of tasks to wake when we're ready to send */
-       struct buffer txbuf;                 /* transmission buffer, always valid (buf_empty or real buffer) */
        void *data;                          /* pointer to upper layer's entity (eg: stream interface) */
        const struct data_cb *data_cb;       /* data layer callbacks. Must be set before xprt->init() */
        void *ctx;                           /* mux-specific context */
index bb50548a1afda3bd47720c09864ce89961ce382b..fa04bc805cde3d1866b853b0ca4af1f992287f4e 100644 (file)
@@ -771,7 +771,7 @@ static void __event_srv_chk_w(struct conn_stream *cs)
                goto out;
 
        if (b_data(&check->bo)) {
-               cs_send(cs, &check->bo, b_data(&check->bo), 0);
+               cs->conn->mux->snd_buf(cs, &check->bo, b_data(&check->bo), 0);
                b_realign_if_empty(&check->bo);
                if (conn->flags & CO_FL_ERROR || cs->flags & CS_FL_ERROR) {
                        chk_report_conn_err(check, errno, 0);
@@ -2699,7 +2699,7 @@ static int tcpcheck_main(struct check *check)
                        int ret;
 
                        __cs_want_send(cs);
-                       ret = cs_send(cs, &check->bo, b_data(&check->bo), 0);
+                       ret = cs->conn->mux->snd_buf(cs, &check->bo, b_data(&check->bo), 0);
                        b_realign_if_empty(&check->bo);
 
                        if (ret <= 0) {
index 2a7fb1b478ebd094a190c4729301e44ec528a51e..df3df8426190f958f147fce1cf36011b93c7b60d 100644 (file)
@@ -383,17 +383,6 @@ int conn_sock_drain(struct connection *conn)
        return 1;
 }
 
-/*
- * default cs send() : this one is used when mux->snd_buf == NULL. It puts up to
- * <count> bytes from <buf> into cs->txbuf. The number of bytes transferred is
- * returned. Here we don't care if cs->txbuf is allocated or not. If not, it
- * will be swapped with <buf>.
- */
-size_t __cs_send(struct conn_stream *cs, struct buffer *buf, size_t count, int flags)
-{
-       return b_xfer(&cs->txbuf, buf, count);
-}
-
 /*
  * Get data length from tlv
  */
index 591d8352b0d7b6fe7785379bdd506f0c7143dad2..f2d6b6f5b0f593529966e13f4c7ec1708416550d 100644 (file)
@@ -721,7 +721,7 @@ static struct task * si_cs_send(struct task *t, void *ctx, unsigned short state)
                if (oc->flags & CF_STREAMER)
                        send_flag |= CO_SFL_STREAMER;
 
-               ret = cs_send(cs, &oc->buf, co_data(oc), send_flag);
+               ret = cs->conn->mux->snd_buf(cs, &oc->buf, co_data(oc), send_flag);
                if (ret > 0) {
                        did_send = 1;
                        oc->flags |= CF_WRITE_PARTIAL | CF_WROTE_DATA | CF_WRITE_EVENT;