From owner-svn-src-all@FreeBSD.ORG Thu Mar 17 21:02:15 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id E95BF106566C; Thu, 17 Mar 2011 21:02:14 +0000 (UTC) (envelope-from trociny@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id D01758FC1A; Thu, 17 Mar 2011 21:02:14 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2HL2EUb039052; Thu, 17 Mar 2011 21:02:14 GMT (envelope-from trociny@svn.freebsd.org) Received: (from trociny@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2HL2EMT039048; Thu, 17 Mar 2011 21:02:14 GMT (envelope-from trociny@svn.freebsd.org) Message-Id: <201103172102.p2HL2EMT039048@svn.freebsd.org> From: Mikolaj Golub Date: Thu, 17 Mar 2011 21:02:14 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r219721 - head/sbin/hastd X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 17 Mar 2011 21:02:15 -0000 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 Tested by: Christian Vogt 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");