cluster: RHEL6 - cman: prevent libcman from causing SIGPIPE when corosync is down

Christine Caulfield chrissie at fedoraproject.org
Thu Dec 20 08:49:02 UTC 2012


Gitweb:        http://git.fedorahosted.org/git/?p=cluster.git;a=commitdiff;h=7f67d0a871e5bbafcd98ceb381deb2539f4b0e93
Commit:        7f67d0a871e5bbafcd98ceb381deb2539f4b0e93
Parent:        2616b150da0fb5e6bb24f9d3483b52ea3a89ef82
Author:        Christine Caulfield <ccaulfie at redhat.com>
AuthorDate:    Thu Dec 20 08:49:56 2012 +0000
Committer:     Christine Caulfield <ccaulfie at redhat.com>
CommitterDate: Thu Dec 20 08:49:56 2012 +0000

cman: prevent libcman from causing SIGPIPE when corosync is down

If corosync goes down/is shut down cman will return 0 from cman_dispatch and
close the socket. However, if a cman write operation is issued before this
happens then SIGPIPE can result from the writev() call to an open, but
disconnected, FD.

This patch changes writev() to sendmg() so it can pass MSG_NOSIGNAL to the
system call and prevent SIGPIPEs from occurring.

Resolves rhbz#887787

Acked-By: Fabio M. Di Nitto <fdinitto at redhat.com>
Signed-off-by: Christine Caulfield <ccaulfie at redhat.com>
---
 cman/lib/libcman.c |   11 ++++++++++-
 1 files changed, 10 insertions(+), 1 deletions(-)

diff --git a/cman/lib/libcman.c b/cman/lib/libcman.c
index a89c731..a99f5a0 100644
--- a/cman/lib/libcman.c
+++ b/cman/lib/libcman.c
@@ -204,10 +204,19 @@ static int loopy_writev(int fd, struct iovec *iovptr, size_t iovlen)
 {
 	size_t byte_cnt=0;
 	int len;
+	struct msghdr msg;
+
+	msg.msg_name = NULL;
+	msg.msg_namelen = 0;
+	msg.msg_control = NULL;
+	msg.msg_controllen = 0;
 
 	while (iovlen > 0)
 	{
-		len = writev(fd, iovptr, iovlen);
+	  msg.msg_iov = iovptr;
+	  msg.msg_iovlen = iovlen;
+
+	  len = sendmsg(fd, &msg, MSG_NOSIGNAL);
 		if (len <= 0)
 			return len;
 


More information about the cluster-commits mailing list