BUG/MEDIUM: process_stream: Don't use si_cs_io_cb() in process_stream().
Instead of using si_cs_io_cb() in process_stream() use si_cs_send/si_cs_recv
instead, as si_cs_io_cb() may lead to process_stream being woken up when it
shouldn't be, and thus timeout would never get triggered.
diff --git a/src/stream.c b/src/stream.c
index b7eb5db..e75491e 100644
--- a/src/stream.c
+++ b/src/stream.c
@@ -1646,6 +1646,8 @@
unsigned int req_ana_back;
struct channel *req, *res;
struct stream_interface *si_f, *si_b;
+ struct conn_stream *cs;
+ int ret;
activity[tid].stream++;
@@ -1656,8 +1658,16 @@
si_b = &s->si[1];
/* First, attempd to do I/Os */
- si_cs_io_cb(NULL, si_f, 0);
- si_cs_io_cb(NULL, si_b, 0);
+ cs = objt_cs(si_f->end);
+ if (cs) {
+ si_cs_send(cs);
+ si_cs_recv(cs);
+ }
+ cs = objt_cs(si_b->end);
+ if (cs) {
+ si_cs_send(cs);
+ si_cs_recv(cs);
+ }
//DPRINTF(stderr, "%s:%d: cs=%d ss=%d(%d) rqf=0x%08x rpf=0x%08x\n", __FUNCTION__, __LINE__,
// si_f->state, si_b->state, si_b->err_type, req->flags, res->flags);
@@ -2489,8 +2499,22 @@
s->pending_events &= ~(TASK_WOKEN_TIMER | TASK_WOKEN_RES);
stream_release_buffers(s);
/* We may have free'd some space in buffers, or have more to send/recv, try again */
- si_cs_io_cb(NULL, si_f, 0);
- si_cs_io_cb(NULL, si_b, 0);
+ cs = objt_cs(si_f->end);
+ ret = 0;
+ if (cs && !(cs->conn->flags & CO_FL_ERROR)) {
+ ret |= si_cs_send(cs);
+ si_cs_recv(cs);
+ ret |= (ci_data(si_ic(si_f)) != 0 ) | (cs->conn->flags & CO_FL_ERROR);
+ }
+ cs = objt_cs(si_b->end);
+ if (cs && !(cs->conn->flags & CO_FL_ERROR)) {
+ ret |= si_cs_send(cs);
+ si_cs_recv(cs);
+ ret |= (ci_data(si_ic(si_b)) != 0 ) | (cs->conn->flags & CO_FL_ERROR);
+
+ }
+ if (ret)
+ task_wakeup(t, TASK_WOKEN_IO);
return t; /* nothing more to do */
}