]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
[MEDIUM] stream_int: adjust WAIT_ROOM handling
authorWilly Tarreau <w@1wt.eu>
Sun, 4 Oct 2009 15:18:35 +0000 (17:18 +0200)
committerWilly Tarreau <w@1wt.eu>
Sun, 4 Oct 2009 15:35:08 +0000 (17:35 +0200)
When applets write data, they generall cannot fill the buffer, so as
soon as we find a non-empty buffer, we're sure we're missing some room.

src/dumpstats.c
src/stream_interface.c

index e8eef21f61f23e3eac3d54bf747d11df45e26c48..3e65ab79a6d8e97c4a5f6cbba62d8b82314ef037 100644 (file)
@@ -438,10 +438,8 @@ void stats_io_handler(struct stream_interface *si)
                        }
 
                        /* If the output functions are still there, it means they require more room. */
-                       if (si->st0 >= STAT_CLI_OUTPUT) {
-                               si->flags |= SI_FL_WAIT_ROOM;
+                       if (si->st0 >= STAT_CLI_OUTPUT)
                                break;
-                       }
 
                        /* Now we close the output if one of the writers did so,
                         * or if we're not in interactive mode and the request
@@ -637,9 +635,6 @@ void http_stats_io_handler(struct stream_interface *si)
                if (stats_dump_http(s, res, s->be->uri_auth)) {
                        si->st0 = 1;
                        si->shutw(si);
-               } else {
-                       /* buffer full */
-                       si->flags |= SI_FL_WAIT_ROOM;
                }
        }
 
index 6f026860f56fc47edce982f2d6684b14c707f1dc..96b26def587bcf37fe574a09b1d6b5015aa08c0f 100644 (file)
@@ -120,7 +120,10 @@ void stream_int_update_embedded(struct stream_interface *si)
        if ((si->ob->flags & (BF_FULL|BF_SHUTW|BF_SHUTW_NOW|BF_HIJACK)) == 0)
                si->flags |= SI_FL_WAIT_DATA;
 
-       if ((si->ib->flags & (BF_FULL|BF_SHUTR)) == BF_FULL)
+       /* we're almost sure that we need some space if the buffer is not
+        * empty, even if it's not full, because the applets can't fill it.
+        */
+       if ((si->ib->flags & (BF_SHUTR|BF_OUT_EMPTY)) == 0)
                si->flags |= SI_FL_WAIT_ROOM;
 
        if (si->ob->flags & BF_WRITE_ACTIVITY) {
@@ -134,10 +137,12 @@ void stream_int_update_embedded(struct stream_interface *si)
                        si->ib->rex = tick_add_ifset(now_ms, si->ib->rto);
        }
 
-       if (si->ob->flags & BF_WRITE_PARTIAL)
+       if (likely((si->ob->flags & (BF_SHUTW|BF_WRITE_PARTIAL|BF_FULL)) == BF_WRITE_PARTIAL &&
+                  (si->ob->prod->flags & SI_FL_WAIT_ROOM)))
                si->ob->prod->chk_rcv(si->ob->prod);
 
-       if (si->ib->flags & BF_READ_PARTIAL)
+       if (((si->ib->flags & (BF_READ_PARTIAL|BF_OUT_EMPTY)) == BF_READ_PARTIAL) &&
+           (si->ib->cons->flags & SI_FL_WAIT_DATA))
                si->ib->cons->chk_snd(si->ib->cons);
 
        /* Note that we're trying to wake up in two conditions here :