From owner-freebsd-arch@FreeBSD.ORG Wed Jul 9 14:21:26 2008 Return-Path: Delivered-To: freebsd-arch@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id AEE7D106567D for ; Wed, 9 Jul 2008 14:21:26 +0000 (UTC) (envelope-from stefan.lambrev@moneybookers.com) Received: from blah.sun-fish.com (blah.sun-fish.com [217.18.249.150]) by mx1.freebsd.org (Postfix) with ESMTP id 681508FC13 for ; Wed, 9 Jul 2008 14:21:26 +0000 (UTC) (envelope-from stefan.lambrev@moneybookers.com) Received: by blah.sun-fish.com (Postfix, from userid 1002) id B8D451B10E4E; Wed, 9 Jul 2008 16:06:03 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.2.4 (2008-01-01) on malcho.cmotd.com X-Spam-Level: X-Spam-Status: No, score=-10.0 required=5.0 tests=ALL_TRUSTED,BAYES_00, J_CHICKENPOX_21 autolearn=no version=3.2.4 Received: from hater.haters.org (hater.cmotd.com [192.168.3.125]) by blah.sun-fish.com (Postfix) with ESMTP id CEC531B10CAA for ; Wed, 9 Jul 2008 16:05:56 +0200 (CEST) Message-ID: <4874C5C4.6080605@moneybookers.com> Date: Wed, 09 Jul 2008 17:05:56 +0300 From: Stefan Lambrev User-Agent: Thunderbird 2.0.0.14 (X11/20080616) MIME-Version: 1.0 To: freebsd-arch@freebsd.org Content-Type: text/plain; charset=windows-1251; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: ClamAV version 0.93, clamav-milter version 0.93 on blah.cmotd.com X-Virus-Status: Clean Subject: Socket not ready problem. X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 09 Jul 2008 14:21:26 -0000 Greetings, I have few apps installed from ports (clamav-milter, spamassassin-milter and etc) which should chown/chmod their socket to allow apps running with different user to connect to them. The problem is that I see some race here. On SMP machine very often the app finish it's execution and next chown/chmod is called, but the socket is not opened/created at this point. Which is very annoying because I have to change my rc.d scripts by hand every time when I update/upgrade. And sometimes I forget ... Can you consider the following patch (or if you like something similar) for inclusion which will then allow rc.d shell script to call a function to wait for the socket and once ready to exit and let chown/chmod start. The function should be called with 2 parameters - socket path and timeout (and we can manage them from rc.conf) --- /usr/src/etc/rc.subr 2008-05-20 11:00:14.000000000 +0200 +++ /etc/rc.subr 2008-05-26 17:59:08.000000000 +0200 @@ -1569,4 +1569,22 @@ fi +wait_for_socket() +{ + _socketpath=$1 + _timeout=$2 + if [ -z "${_socketpath}" -o -z "${_timeout}" ]; then + err 3 'USAGE: wait_for_socket socketpath timeout' + fi + + while [ ${_timeout} -gt 0 ] + do + [ -S "${_socketpath}" ] && break + echo -n "." + sleep 1 + _timeout=$((${_timeout}-1)) + done + echo +} + _rc_subr_loaded=: -- Best Wishes, Stefan Lambrev ICQ# 24134177