Protect the invariants
PATCH 2/6 Protect the invariants
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.
server/object.c +6 -0
@@ -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);
server/server.c +4 -5
@@ -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 ;