[bind10-dev] How to avoid multiple xfrout processes running at same time
Shane Kerr
shane at isc.org
Wed Jun 2 11:15:12 UTC 2010
All,
On Tue, 2010-06-01 at 17:30 +0800, zhanglikun wrote:
> My question is: how to make sure there is only one xfrout process
> running on server?(Xfrout runs as one unix socket server).
Likun and I talked about this, and came up with the solution documented
in ticket #151:
http://bind10.isc.org/ticket/151#comment:13
Which is:
------------------------------------------------------------------------
If you try to bind() to an AF_UNIX socket, it will fail if any file
exists, even an unused AF_UNIX socket. So, what we will do is try to
connect() first. In this case one of 3 things happens:
1. If there is no file, you get a socket.error with ENOENT
2. If there is a file, but it is not a socket or nobody is
listening, you get socket.err with ECONNREFUSED
3. If there is a listener, then the connect() will succeed
So if another copy of xfrout is running, the connect() will succeed, and
we can exit with appropriate warning/error message at that time.
Otherwise, we get an error and we can safely start.
------------------------------------------------------------------------
Likun coded this up, and also made sure that we actually delete the
socket file before the bind() call. So... yay. :)
--
Shane
More information about the bind10-dev
mailing list