From owner-svn-src-all@FreeBSD.ORG Mon Aug 30 00:12:11 2010 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 6B20A1065696; Mon, 30 Aug 2010 00:12:11 +0000 (UTC) (envelope-from pjd@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 403EC8FC12; Mon, 30 Aug 2010 00:12:11 +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 o7U0CB6s078435; Mon, 30 Aug 2010 00:12:11 GMT (envelope-from pjd@svn.freebsd.org) Received: (from pjd@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o7U0CBoj078431; Mon, 30 Aug 2010 00:12:11 GMT (envelope-from pjd@svn.freebsd.org) Message-Id: <201008300012.o7U0CBoj078431@svn.freebsd.org> From: Pawel Jakub Dawidek Date: Mon, 30 Aug 2010 00:12:11 +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: r211983 - 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: Mon, 30 Aug 2010 00:12:11 -0000 Author: pjd Date: Mon Aug 30 00:12:10 2010 New Revision: 211983 URL: http://svn.freebsd.org/changeset/base/211983 Log: Execute hook when split-brain is detected. MFC after: 2 weeks Obtained from: Wheel Systems Sp. z o.o. http://www.wheelsystems.com Modified: head/sbin/hastd/hast.conf.5 head/sbin/hastd/primary.c head/sbin/hastd/secondary.c Modified: head/sbin/hastd/hast.conf.5 ============================================================================== --- head/sbin/hastd/hast.conf.5 Mon Aug 30 00:06:05 2010 (r211982) +++ head/sbin/hastd/hast.conf.5 Mon Aug 30 00:12:10 2010 (r211983) @@ -232,6 +232,11 @@ between the nodes. .Pp Executed on both primary and secondary nodes when resource role is changed. .Pp +.It Ic " split-brain " +.Pp +Executed on both primary and secondary nodes when split-brain condition is +detected. +.Pp .El The .Aq path Modified: head/sbin/hastd/primary.c ============================================================================== --- head/sbin/hastd/primary.c Mon Aug 30 00:06:05 2010 (r211982) +++ head/sbin/hastd/primary.c Mon Aug 30 00:12:10 2010 (r211983) @@ -498,6 +498,7 @@ init_remote(struct hast_resource *res, s assert(real_remote(res)); in = out = NULL; + errmsg = NULL; /* Prepare outgoing connection with remote node. */ if (proto_client(res->hr_remoteaddr, &out) < 0) { @@ -673,6 +674,8 @@ init_remote(struct hast_resource *res, s } return (true); close: + if (errmsg != NULL && strcmp(errmsg, "Split-brain condition!") == 0) + hook_exec(res->hr_exec, "split-brain", res->hr_name, NULL); proto_close(out); if (in != NULL) proto_close(in); Modified: head/sbin/hastd/secondary.c ============================================================================== --- head/sbin/hastd/secondary.c Mon Aug 30 00:06:05 2010 (r211982) +++ head/sbin/hastd/secondary.c Mon Aug 30 00:12:10 2010 (r211983) @@ -323,6 +323,7 @@ init_remote(struct hast_resource *res, s if (res->hr_secondary_localcnt > res->hr_primary_remotecnt && res->hr_primary_localcnt > res->hr_secondary_remotecnt) { /* Exit on split-brain. */ + hook_exec(res->hr_exec, "split-brain", res->hr_name, NULL); exit(EX_CONFIG); } } @@ -373,6 +374,7 @@ hastd_secondary(struct hast_resource *re if (proto_timeout(res->hr_remoteout, res->hr_timeout) < 0) pjdlog_errno(LOG_WARNING, "Unable to set connection timeout"); + hook_init(); init_local(res); init_remote(res, nvin); init_environment();