cluster-devel.redhat.com archive mirror
 help / color / mirror / Atom feed
From: Jan Pokorný <jpokorny@redhat.com>
To: cluster-devel.redhat.com
Subject: [Cluster-devel] [PATCH 2/2] libcman: remove superfluous cman_dispatch outer loop condition
Date: Tue,  9 Oct 2012 20:31:28 +0200	[thread overview]
Message-ID: <1349807488-29871-3-git-send-email-jpokorny@redhat.com> (raw)
In-Reply-To: <1349807488-29871-1-git-send-email-jpokorny@redhat.com>

My grasp is that "len < 0" will never occur@the point of condition
check [*].  Under this assumption, the other check (for errno != EAGAIN)
does not decide anything, only making the code more obfuscated.

Please note that there used to be some discrepancies around in the past,
notably see commit bd910f7e9de2d320f10a12cd9a3e7a26fb00083a.

[*] proof is left ... ok, below:

We consider CMAN_DISPATCH_ALL only as it is prerequisite to even get
further in the evaluation of the discussed condition.

1. we can get into the loop condition when processing a message from
   the waitlist and "len" is then set to the lenght of such handled
   message

   1a. message is added to the waitlist only indirectly from within
       cman_dispatch, but cman_dispatch may proceed a received
       message this far only if it was indeed received OK
       (this includes nonzero lenght indicated in the header part
       [although this is not checked directly], which is exactly
       the value set to "len" checked in the discussed condition)

   1b. hence, "len" cannot be negative when we reach the condition
       this way (effectively skipping final errno comparison)

2. we can get into the loop condition also after processing directly
   received message, where "len" carries the return value of either
   recv or read

   2a. any case of negative-or-zero "len" is captured immediately
       after setting it, always resulting in returning from call

   2b. ditto 1b.

3. 1b. + 2b. -> Q.E.D.

Please correct me if I am wrong.

Signed-off-by: Jan Pokorn? <jpokorny@redhat.com>
---
 cman/lib/libcman.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/cman/lib/libcman.c b/cman/lib/libcman.c
index 26c09f2..4ecdd35 100644
--- a/cman/lib/libcman.c
+++ b/cman/lib/libcman.c
@@ -554,8 +554,7 @@ int cman_dispatch(cman_handle_t handle, int flags)
 		if (res)
 			break;
 
-	} while ( flags & CMAN_DISPATCH_ALL &&
-		  !(len < 0 && errno == EAGAIN) );
+	} while (flags & CMAN_DISPATCH_ALL);
 
 	return len;
 }
-- 
1.7.11.4



      parent reply	other threads:[~2012-10-09 18:31 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-10-09 18:31 [Cluster-devel] [PATCH 0/2][RFC] pruning libcman a bit Jan Pokorný
2012-10-09 18:31 ` [Cluster-devel] [PATCH 1/2] libcman: E{INTR, AGAIN} in cman_dispatch repeated read needs -1 too Jan Pokorný
2012-10-09 18:31 ` Jan Pokorný [this message]

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=1349807488-29871-3-git-send-email-jpokorny@redhat.com \
    --to=jpokorny@redhat.com \
    /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;
as well as URLs for NNTP newsgroup(s).