Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 14 Nov 2010 11:16:18 +0200
From:      Mikolaj Golub <to.my.trociny@gmail.com>
To:        freebsd-fs@freebsd.org
Cc:        Pawel Jakub Dawidek <pjd@freebsd.org>
Subject:   hastd/primary.c micro fixes
Message-ID:  <86wrogqn8d.fsf@kopusha.home.net>

next in thread | raw e-mail | index | archive | help
--=-=-=

Hi,

noticed the following in hastd/primary.c:

1) in init_remote() when incoming connection is set up, if proto_client()
fails it only reports about the error and try proto_connect() anyway. This
will cause a crash as proto_conn structure is not valid. Primary should rather
exit (as it is when outgoing connection is set up, and as it is in the patch
below) or set proto_conn pointer to NULL and goto close.

2) in guard_thread() timeout.tv_sec is set in loop, while it looks like it may
be set only once before the loop.

-- 
Mikolaj Golub


--=-=-=
Content-Type: text/x-patch
Content-Disposition: inline; filename=primary.c.patch

Index: sbin/hastd/primary.c
===================================================================
--- sbin/hastd/primary.c	(revision 215165)
+++ sbin/hastd/primary.c	(working copy)
@@ -577,7 +577,7 @@ init_remote(struct hast_resource *res, struct prot
 	 * Setup incoming connection with remote node.
 	 */
 	if (proto_client(res->hr_remoteaddr, &in) < 0) {
-		pjdlog_errno(LOG_WARNING, "Unable to create connection to %s",
+		primary_exit(EX_TEMPFAIL, "Unable to create connection to %s",
 		    res->hr_remoteaddr);
 	}
 	/* Try to connect, but accept failure. */
@@ -2008,6 +2008,7 @@ guard_thread(void *arg)
 	PJDLOG_VERIFY(sigaddset(&mask, SIGINT) == 0);
 	PJDLOG_VERIFY(sigaddset(&mask, SIGTERM) == 0);
 
+	timeout.tv_sec = RETRY_SLEEP;
 	timeout.tv_nsec = 0;
 	signo = -1;
 
@@ -2033,7 +2034,6 @@ guard_thread(void *arg)
 				guard_one(res, ii);
 			lastcheck = now;
 		}
-		timeout.tv_sec = RETRY_SLEEP;
 		signo = sigtimedwait(&mask, NULL, &timeout);
 	}
 	/* NOTREACHED */

--=-=-=--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?86wrogqn8d.fsf>