I am unable to ensure that the invariants such as having something in
write_q upon restart are not violated, ever. So, let's rearrange the
code a little bit to make sure.

[Before sending I noticed that this patch included a piece of other,
unrelated patch. However, this passed tests on its own (because
cli_wr_set_poll never returns an error). So in the interests of
not screwing up further, sending as-is.]

Signed-off-by: Pete Zaitcev <[email protected]>

---
 server/object.c |    6 ++++++
 server/server.c |    9 ++++-----
 2 files changed, 10 insertions(+), 5 deletions(-)

commit 75d01d61e9ca55d244120cbbd7f338f07f03e9b6
Author: Master <[email protected]>
Date:   Thu May 20 21:26:55 2010 -0600

    Protect the invariants.

diff --git a/server/object.c b/server/object.c
index 40ef4c4..7f6341a 100644
--- a/server/object.c
+++ b/server/object.c
@@ -342,6 +342,12 @@ bool object_get(struct client *cli, bool want_body)
                goto start_write;
        }
 
+       if (!cli->in_len) {
+               applog(LOG_INFO, "zero-sized object");
+               cli_in_end(cli);
+               goto start_write;
+       }
+
        if (!object_read_bytes(cli)) {
                cli_in_end(cli);
                return cli_err(cli, err, false);
diff --git a/server/server.c b/server/server.c
index 07d0375..de9e6a8 100644
--- a/server/server.c
+++ b/server/server.c
@@ -529,14 +529,13 @@ do_write:
 
        cli_wr_completed(cli, rc, &more_work);
 
-       if (more_work)
-               goto restart;
-
        /* if we emptied the queue, clear write notification */
        if (list_empty(&cli->write_q)) {
                cli->writing = false;
-               if (!cli_wr_set_poll(cli, false))
-                       goto err_out;
+               cli_wr_set_poll(cli, false);
+       } else {
+               if (more_work)
+                       goto restart;
        }
 
        return;
--
To unsubscribe from this list: send the line "unsubscribe hail-devel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to