]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MEDIUM: stream-interface: offer a generic chk_rcv function for connections
authorWilly Tarreau <wtarreau@exceliance.fr>
Mon, 20 Aug 2012 10:38:36 +0000 (12:38 +0200)
committerWilly Tarreau <w@1wt.eu>
Sun, 2 Sep 2012 19:54:18 +0000 (21:54 +0200)
sock_raw and sock_ssl use a pretty generic chk_rcv function, so let's move
this function to the stream_interface and remove specific functions. Later
we might have a single chk_rcv function.

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

index 5e2d74f6b8a19fb11603421fc9eb913befbc7276..24072a61207526baf306271c09c3a116df7d18f4 100644 (file)
@@ -39,6 +39,7 @@ void conn_notify_si(struct connection *conn);
 void stream_int_update_conn(struct stream_interface *si);
 int stream_int_shutr(struct stream_interface *si);
 int stream_int_shutw(struct stream_interface *si);
+void stream_int_chk_rcv_conn(struct stream_interface *si);
 
 extern struct sock_ops stream_int_embedded;
 extern struct sock_ops stream_int_task;
index 6a3a2565cfa3de10a20358e559a2fede07f71231..c426e995b5ac5cbb266f782c2977eabfd21ea536 100644 (file)
@@ -46,7 +46,6 @@
 static void sock_raw_read(struct connection *conn);
 static void sock_raw_write(struct connection *conn);
 static void sock_raw_read0(struct stream_interface *si);
-static void sock_raw_chk_rcv(struct stream_interface *si);
 static void sock_raw_chk_snd(struct stream_interface *si);
 
 
@@ -673,40 +672,6 @@ static void sock_raw_read0(struct stream_interface *si)
        return;
 }
 
-/* This function is used for inter-stream-interface calls. It is called by the
- * consumer to inform the producer side that it may be interested in checking
- * for free space in the buffer. Note that it intentionally does not update
- * timeouts, so that we can still check them later at wake-up.
- */
-static void sock_raw_chk_rcv(struct stream_interface *si)
-{
-       struct buffer *ib = si->ib;
-
-       DPRINTF(stderr,"[%u] %s: fd=%d owner=%p ib=%p, ob=%p, exp(r,w)=%u,%u ibf=%08x obf=%08x ibh=%d ibt=%d obh=%d obd=%d si=%d\n",
-               now_ms, __FUNCTION__,
-               si_fd(si), fdtab[si_fd(si)].owner,
-               ib, si->ob,
-               ib->rex, si->ob->wex,
-               ib->flags, si->ob->flags,
-               ib->i, ib->o, si->ob->i, si->ob->o, si->state);
-
-       if (unlikely(si->state != SI_ST_EST || (ib->flags & BF_SHUTR)))
-               return;
-
-       if (ib->flags & (BF_FULL|BF_HIJACK|BF_DONT_READ)) {
-               /* stop reading */
-               if ((ib->flags & (BF_FULL|BF_HIJACK|BF_DONT_READ)) == BF_FULL)
-                       si->flags |= SI_FL_WAIT_ROOM;
-               conn_data_stop_recv(&si->conn);
-       }
-       else {
-               /* (re)start reading */
-               si->flags &= ~SI_FL_WAIT_ROOM;
-               conn_data_want_recv(&si->conn);
-       }
-}
-
-
 /* This function is used for inter-stream-interface calls. It is called by the
  * producer to inform the consumer side that it may be interested in checking
  * for data in the buffer. Note that it intentionally does not update timeouts,
@@ -811,7 +776,7 @@ struct sock_ops sock_raw = {
        .update  = stream_int_update_conn,
        .shutr   = NULL,
        .shutw   = NULL,
-       .chk_rcv = sock_raw_chk_rcv,
+       .chk_rcv = stream_int_chk_rcv_conn,
        .chk_snd = sock_raw_chk_snd,
        .read    = sock_raw_read,
        .write   = sock_raw_write,
index e3816e414f1ed6e6681e62838386eb0c5cecb1c1..6a46df40a46ea7891292cc861f07005e70269591 100644 (file)
@@ -734,6 +734,38 @@ void stream_int_update_conn(struct stream_interface *si)
        }
 }
 
+/* This function is used for inter-stream-interface calls. It is called by the
+ * consumer to inform the producer side that it may be interested in checking
+ * for free space in the buffer. Note that it intentionally does not update
+ * timeouts, so that we can still check them later at wake-up. This function is
+ * dedicated to connection-based stream interfaces.
+ */
+void stream_int_chk_rcv_conn(struct stream_interface *si)
+{
+       struct buffer *ib = si->ib;
+
+       if (unlikely(si->state != SI_ST_EST || (ib->flags & BF_SHUTR)))
+               return;
+
+       if (si->conn.flags & CO_FL_HANDSHAKE) {
+               /* a handshake is in progress */
+               return;
+       }
+
+       if (ib->flags & (BF_FULL|BF_HIJACK|BF_DONT_READ)) {
+               /* stop reading */
+               if ((ib->flags & (BF_FULL|BF_HIJACK|BF_DONT_READ)) == BF_FULL)
+                       si->flags |= SI_FL_WAIT_ROOM;
+               conn_data_stop_recv(&si->conn);
+       }
+       else {
+               /* (re)start reading */
+               si->flags &= ~SI_FL_WAIT_ROOM;
+               conn_data_want_recv(&si->conn);
+       }
+}
+
+
 /*
  * Local variables:
  *  c-indent-level: 8