]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MEDIUM: connection: don't use real send() flags in snd_buf()
authorWilly Tarreau <w@1wt.eu>
Sun, 2 Feb 2014 00:51:17 +0000 (01:51 +0100)
committerWilly Tarreau <w@1wt.eu>
Thu, 6 Feb 2014 10:37:29 +0000 (11:37 +0100)
This prevents us from passing other useful info and requires the
upper levels to know these flags. Let's use a new flags category
instead : CO_SFL_*. For now, only MSG_MORE has been remapped.

include/types/connection.h
src/checks.c
src/raw_sock.c
src/ssl_sock.c
src/stream_interface.c

index eb9307fbc745ce55f1c75d9d59e307f1f67b3c33..f8e526ac4955bc65dbeb765cc4743e0d633f86e6 100644 (file)
@@ -177,6 +177,10 @@ enum {
        CO_SRC_BIND        = 0x0008,    /* bind to a specific source address when connecting */
 };
 
+/* flags that can be passed to xprt->snd_buf() */
+enum {
+       CO_SFL_MSG_MORE    = 0x0001,    /* More data to come afterwards */
+};
 
 /* xprt_ops describes transport-layer operations for a connection. They
  * generally run over a socket-based control layer, but not always. Some
index b195c73bf39009c435edb1d2fb824c9e3e70e76c..c9a531f32ede9ed350a131ac3d6389f845fdc0ee 100644 (file)
@@ -971,7 +971,7 @@ static void event_srv_chk_w(struct connection *conn)
        }
 
        if (check->bo->o) {
-               conn->xprt->snd_buf(conn, check->bo, MSG_DONTWAIT | MSG_NOSIGNAL);
+               conn->xprt->snd_buf(conn, check->bo, 0);
                if (conn->flags & CO_FL_ERROR) {
                        chk_report_conn_err(conn, errno, 0);
                        __conn_data_stop_both(conn);
@@ -2037,7 +2037,7 @@ static void tcpcheck_main(struct connection *conn)
                     check->current_step->action != TCPCHK_ACT_SEND ||
                     check->current_step->string_len >= buffer_total_space(check->bo))) {
 
-                       if (conn->xprt->snd_buf(conn, check->bo, MSG_DONTWAIT | MSG_NOSIGNAL) <= 0) {
+                       if (conn->xprt->snd_buf(conn, check->bo, 0) <= 0) {
                                if (conn->flags & CO_FL_ERROR) {
                                        chk_report_conn_err(conn, errno, 0);
                                        __conn_data_stop_both(conn);
index 4b125ceb40ae95ea56723fd966f18df245338025..3708b19847651cb5e13db7bc6ef758655b065175 100644 (file)
@@ -341,8 +341,8 @@ static int raw_sock_to_buf(struct connection *conn, struct buffer *buf, int coun
 
 
 /* Send all pending bytes from buffer <buf> to connection <conn>'s socket.
- * <flags> may contain MSG_MORE to make the system hold on without sending
- * data too fast.
+ * <flags> may contain some CO_SFL_* flags to hint the system about other
+ * pending data for example.
  * Only one call to send() is performed, unless the buffer wraps, in which case
  * a second call may be performed. The connection's flags are updated with
  * whatever special event is detected (error, empty). The caller is responsible
@@ -372,10 +372,10 @@ static int raw_sock_from_buf(struct connection *conn, struct buffer *buf, int fl
                        try = buf->data + try - buf->p;
 
                send_flag = MSG_DONTWAIT | MSG_NOSIGNAL;
-               if (try < buf->o)
+               if (try < buf->o || flags & CO_SFL_MSG_MORE)
                        send_flag |= MSG_MORE;
 
-               ret = send(conn->t.sock.fd, bo_ptr(buf), try, send_flag | flags);
+               ret = send(conn->t.sock.fd, bo_ptr(buf), try, send_flag);
 
                if (ret > 0) {
                        buf->o -= ret;
index 7107a31abdc153f6b66bf64bec90eb6195cf2c42..19505e5ee26b145e8b8d3fccb92038b9fa814e2e 100644 (file)
@@ -1499,8 +1499,8 @@ static int ssl_sock_to_buf(struct connection *conn, struct buffer *buf, int coun
 
 
 /* Send all pending bytes from buffer <buf> to connection <conn>'s socket.
- * <flags> may contain MSG_MORE to make the system hold on without sending
- * data too fast, but this flag is ignored at the moment.
+ * <flags> may contain some CO_SFL_* flags to hint the system about other
+ * pending data for example, but this flag is ignored at the moment.
  * Only one call to send() is performed, unless the buffer wraps, in which case
  * a second call may be performed. The connection's flags are updated with
  * whatever special event is detected (error, empty). The caller is responsible
index c4d271542d0b82daa3a30e2492be3317490fe33e..967f6451c59c3beffdc176ed49ca2baa34ecd6b9 100644 (file)
@@ -693,13 +693,13 @@ static void si_conn_send(struct connection *conn)
                 * The test is arranged so that the most common case does only 2
                 * tests.
                 */
-               unsigned int send_flag = MSG_DONTWAIT | MSG_NOSIGNAL;
+               unsigned int send_flag = 0;
 
                if ((!(chn->flags & (CF_NEVER_WAIT|CF_SEND_DONTWAIT)) &&
                     ((chn->to_forward && chn->to_forward != CHN_INFINITE_FORWARD) ||
                      (chn->flags & CF_EXPECT_MORE))) ||
                    ((chn->flags & (CF_SHUTW|CF_SHUTW_NOW)) == CF_SHUTW_NOW))
-                       send_flag |= MSG_MORE;
+                       send_flag |= CO_SFL_MSG_MORE;
 
                ret = conn->xprt->snd_buf(conn, chn->buf, send_flag);
                if (ret > 0) {