Date: Wed, 09 Jul 2008 17:05:56 +0300 From: Stefan Lambrev <stefan.lambrev@moneybookers.com> To: freebsd-arch@freebsd.org Subject: Socket not ready problem. Message-ID: <4874C5C4.6080605@moneybookers.com>
next in thread | raw e-mail | index | archive | help
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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?4874C5C4.6080605>