]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
[MEDIUM] session: make it possible to call an I/O handler on both SI
authorWilly Tarreau <w@1wt.eu>
Tue, 13 Jul 2010 14:30:45 +0000 (16:30 +0200)
committerWilly Tarreau <w@1wt.eu>
Tue, 13 Jul 2010 14:34:26 +0000 (16:34 +0200)
This will be used when an I/O handler running in a stream interface
needs to establish a connection somewhere. We want the session
processor to evaluate both I/O handlers, depending on which side has
one. Doing so also requires that stream_int_update_embedded() wakes
the session up only when the other side is established or has closed,
for instance in order to handle connection errors without looping
indefinitely during the connection setup time.

The session processor still relies on BF_READ_ATTACHED being set,
though we must do whatever is required to remove this dependency.

src/session.c
src/stream_interface.c

index 10c7f13d613a52576ca1a3a2f135717d01e1ebc6..acd9770311d51f7e87ebc7255db68766645ad73c 100644 (file)
@@ -1821,11 +1821,14 @@ resync_stream_interface:
                        s->req->rex = TICK_ETERNITY;
                }
 
-               /* Call the second stream interface's I/O handler if it's embedded.
+               /* Call the stream interfaces' I/O handlers when embedded.
                 * Note that this one may wake the task up again.
                 */
-               if (s->req->cons->iohandler) {
-                       s->req->cons->iohandler(s->req->cons);
+               if (s->req->cons->iohandler || s->rep->cons->iohandler) {
+                       if (s->req->cons->iohandler)
+                               s->req->cons->iohandler(s->req->cons);
+                       if (s->rep->cons->iohandler)
+                               s->rep->cons->iohandler(s->rep->cons);
                        if (task_in_rq(t)) {
                                /* If we woke up, we don't want to requeue the
                                 * task to the wait queue, but rather requeue
index 113f01c65d032a8cb3c3b4e3b92ea143afddd7c3..9d2f9c5eb0e1e10f57090b32c7b216144d5f68c5 100644 (file)
@@ -142,7 +142,7 @@ void stream_int_update_embedded(struct stream_interface *si)
         *    the to only rely the changes the chk_* might have performed.
         */
        if (/* check stream interface changes */
-           (si->flags & SI_FL_ERR) || si->state != SI_ST_EST || si->ib->cons->state != SI_ST_EST ||
+           (si->flags & SI_FL_ERR) || si->state != SI_ST_EST || si->ib->cons->state > SI_ST_EST ||
            /* check response buffer changes */
            (si->ib->flags & (BF_READ_NULL|BF_READ_ERROR|BF_READ_DONTWAIT)) ||
            ((si->ib->flags & BF_READ_ACTIVITY) && !si->ib->to_forward) ||