MEDIUM: stream-interface: offer a generic chk_rcv function for connections
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.
diff --git a/include/proto/stream_interface.h b/include/proto/stream_interface.h
index 5e2d74f..24072a6 100644
--- a/include/proto/stream_interface.h
+++ b/include/proto/stream_interface.h
@@ -39,6 +39,7 @@
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;
diff --git a/src/sock_raw.c b/src/sock_raw.c
index 6a3a256..c426e99 100644
--- a/src/sock_raw.c
+++ b/src/sock_raw.c
@@ -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);
@@ -674,40 +673,6 @@
}
/* 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,
* so that we can still check them later at wake-up.
@@ -811,7 +776,7 @@
.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,
diff --git a/src/stream_interface.c b/src/stream_interface.c
index e3816e4..6a46df4 100644
--- a/src/stream_interface.c
+++ b/src/stream_interface.c
@@ -734,6 +734,38 @@
}
}
+/* 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