Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 17 Mar 2011 21:02:14 +0000 (UTC)
From:      Mikolaj Golub <trociny@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r219721 - head/sbin/hastd
Message-ID:  <201103172102.p2HL2EMT039048@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: trociny
Date: Thu Mar 17 21:02:14 2011
New Revision: 219721
URL: http://svn.freebsd.org/changeset/base/219721

Log:
  For secondary, set 2 * HAST_KEEPALIVE seconds timeout for incoming
  connection so the worker will exit if it does not receive packets from
  the primary during this interval.
  
  Reported by:	Christian Vogt <Christian.Vogt@haw-hamburg.de>
  Tested by:	Christian Vogt <Christian.Vogt@haw-hamburg.de>
  Approved by:	pjd (mentor)
  MFC after:	1 week

Modified:
  head/sbin/hastd/hast.h
  head/sbin/hastd/primary.c
  head/sbin/hastd/secondary.c

Modified: head/sbin/hastd/hast.h
==============================================================================
--- head/sbin/hastd/hast.h	Thu Mar 17 19:48:31 2011	(r219720)
+++ head/sbin/hastd/hast.h	Thu Mar 17 21:02:14 2011	(r219721)
@@ -98,6 +98,9 @@
 #define	HAST_ADDRSIZE	1024
 #define	HAST_TOKEN_SIZE	16
 
+/* Number of seconds to sleep between reconnect retries or keepalive packets. */
+#define	HAST_KEEPALIVE	10
+
 struct hastd_config {
 	/* Address to communicate with hastctl(8). */
 	char	 hc_controladdr[HAST_ADDRSIZE];

Modified: head/sbin/hastd/primary.c
==============================================================================
--- head/sbin/hastd/primary.c	Thu Mar 17 19:48:31 2011	(r219720)
+++ head/sbin/hastd/primary.c	Thu Mar 17 21:02:14 2011	(r219721)
@@ -150,10 +150,6 @@ static pthread_mutex_t metadata_lock;
  * and remote components.
  */
 #define	HAST_NCOMPONENTS	2
-/*
- * Number of seconds to sleep between reconnect retries or keepalive packets.
- */
-#define	RETRY_SLEEP		10
 
 #define	ISCONNECTED(res, no)	\
 	((res)->hr_remotein != NULL && (res)->hr_remoteout != NULL)
@@ -1318,10 +1314,10 @@ remote_send_thread(void *arg)
 
 	for (;;) {
 		pjdlog_debug(2, "remote_send: Taking request.");
-		QUEUE_TAKE1(hio, send, ncomp, RETRY_SLEEP);
+		QUEUE_TAKE1(hio, send, ncomp, HAST_KEEPALIVE);
 		if (hio == NULL) {
 			now = time(NULL);
-			if (lastcheck + RETRY_SLEEP <= now) {
+			if (lastcheck + HAST_KEEPALIVE <= now) {
 				keepalive_send(res, ncomp);
 				lastcheck = now;
 			}
@@ -2098,7 +2094,7 @@ guard_thread(void *arg)
 	PJDLOG_VERIFY(sigaddset(&mask, SIGINT) == 0);
 	PJDLOG_VERIFY(sigaddset(&mask, SIGTERM) == 0);
 
-	timeout.tv_sec = RETRY_SLEEP;
+	timeout.tv_sec = HAST_KEEPALIVE;
 	timeout.tv_nsec = 0;
 	signo = -1;
 
@@ -2116,7 +2112,7 @@ guard_thread(void *arg)
 
 		pjdlog_debug(2, "remote_guard: Checking connections.");
 		now = time(NULL);
-		if (lastcheck + RETRY_SLEEP <= now) {
+		if (lastcheck + HAST_KEEPALIVE <= now) {
 			for (ii = 0; ii < ncomps; ii++)
 				guard_one(res, ii);
 			lastcheck = now;

Modified: head/sbin/hastd/secondary.c
==============================================================================
--- head/sbin/hastd/secondary.c	Thu Mar 17 19:48:31 2011	(r219720)
+++ head/sbin/hastd/secondary.c	Thu Mar 17 21:02:14 2011	(r219721)
@@ -418,7 +418,7 @@ hastd_secondary(struct hast_resource *re
 	PJDLOG_VERIFY(sigprocmask(SIG_SETMASK, &mask, NULL) == 0);
 
 	/* Error in setting timeout is not critical, but why should it fail? */
-	if (proto_timeout(res->hr_remotein, 0) < 0)
+	if (proto_timeout(res->hr_remotein, 2 * HAST_KEEPALIVE) < 0)
 		pjdlog_errno(LOG_WARNING, "Unable to set connection timeout");
 	if (proto_timeout(res->hr_remoteout, res->hr_timeout) < 0)
 		pjdlog_errno(LOG_WARNING, "Unable to set connection timeout");



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