public inbox for hail-devel@vger.kernel.org
 help / color / mirror / Atom feed
From: Pete Zaitcev <zaitcev@redhat.com>
To: Jeff Garzik <jeff@garzik.org>
Cc: Project Hail List <hail-devel@vger.kernel.org>
Subject: [chunkd patch 2/6] Protect the invariants
Date: Thu, 20 May 2010 22:54:09 -0600	[thread overview]
Message-ID: <20100520225409.23701e40@redhat.com> (raw)

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 <zaitcev@redhat.com>

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

commit 75d01d61e9ca55d244120cbbd7f338f07f03e9b6
Author: Master <zaitcev@lembas.zaitcev.lan>
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;

                 reply	other threads:[~2010-05-21  4:54 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20100520225409.23701e40@redhat.com \
    --to=zaitcev@redhat.com \
    --cc=hail-devel@vger.kernel.org \
    --cc=jeff@garzik.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox