From owner-freebsd-fs@FreeBSD.ORG Sun Nov 14 09:16:24 2010 Return-Path: Delivered-To: freebsd-fs@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id DFB601065697; Sun, 14 Nov 2010 09:16:24 +0000 (UTC) (envelope-from to.my.trociny@gmail.com) Received: from mail-fx0-f54.google.com (mail-fx0-f54.google.com [209.85.161.54]) by mx1.freebsd.org (Postfix) with ESMTP id 4BE788FC12; Sun, 14 Nov 2010 09:16:23 +0000 (UTC) Received: by fxm19 with SMTP id 19so3285058fxm.13 for ; Sun, 14 Nov 2010 01:16:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:from:to:cc:subject:date :message-id:user-agent:mime-version:content-type; bh=7ufVHBxTzW6RDxdwnfZLdfIsKcLjd4xfmxAYKUhXfkE=; b=YjhXfuRYI+YlYTX2T8XOfQQehBE8s70T48C2VV3hYVrFzbdFwkF7b33XDkBRU+VBdY PcsZ1VG3+IO0Kxoqfb43K/t/6JyqN8K0AFs+2YEeSRTWgSuPKnXu0rj7DLeN3rudDG8i R36jioscfE3vhb+LWMrs0YkCOhlw5zuXS4/HY= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:cc:subject:date:message-id:user-agent:mime-version :content-type; b=koUehaifA23hslzsaKVPI8EbStCyl8wy85XZEDn4C0ud8PtoOPfI3K3kpeMu76xpPv MBwemCx0pi3Qrm9NLvve0wqSe3+REIYPV8eYm8bTOHyZN5R6Geq/k45XnfSipiREuE+G 3ukCYEPti6XB1lBTJjNKuEQ2k4DdRw8FZdHk0= Received: by 10.223.86.197 with SMTP id t5mr3535804fal.38.1289726182498; Sun, 14 Nov 2010 01:16:22 -0800 (PST) Received: from localhost ([95.69.174.185]) by mx.google.com with ESMTPS id a25sm523695fab.13.2010.11.14.01.16.20 (version=TLSv1/SSLv3 cipher=RC4-MD5); Sun, 14 Nov 2010 01:16:21 -0800 (PST) From: Mikolaj Golub To: freebsd-fs@freebsd.org Date: Sun, 14 Nov 2010 11:16:18 +0200 Message-ID: <86wrogqn8d.fsf@kopusha.home.net> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.2 (berkeley-unix) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Cc: Pawel Jakub Dawidek Subject: hastd/primary.c micro fixes X-BeenThere: freebsd-fs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Filesystems List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 14 Nov 2010 09:16:25 -0000 --=-=-= 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 */ --=-=-=--