durusmail: durus-users: Small suggestion for Unix sockets in Durus
Small suggestion for Unix sockets in Durus
2006-05-16
2006-05-16
2006-05-16
Small suggestion for Unix sockets in Durus
Jesus Cea
2006-05-16
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Durus release 3.4 adds support for Unix domain sockets. That is very
nice, since we now can do access control over Durus storage server.

There is a problem, nevertheless. A unix socket is persistent. That is,
it creates a "socket" file in the filesystem. This file will persist
even if the durus server dies or the machine is rebooted.

But if the socket file exists, a durus server can't create a new socket
with that name. That is, if the durus server dies (or the machine
reboots), the socket file is left behind and no other durus server can
be launched with that unix address. Until that file is deleted manually,
of course.

I would like to be able to automatize the procedure. I propose the
following algorithm:

a. Each unix socket "x" has an associated lock file "x.lock".

b. Before trying to bind the unix socket, try to lock "x.lock". If the
locking fails, then another server already owns the unix socket. Die
gracefully.

c. If we can lock the file, then no other durus server is using that
unix socket. We can delete the unix domain socket file and "bind" to it
again, without risk.

PS: Yes, I know that I can delete the unix socket file while the machine
is booting, but if the durus server dies and I relaunch it, I can't be
sure I'm launching a single server. The lock ensures that only a single
durus server is running, and if none is running, we will know it.

PPS: Having a way to specify a file mode (umask) for the unix domain
socket would be nice. Also owner/group, if we are running as root. Maybe
a parameter to execute an arbitrary external function instead of the
"bind" would be nice. So I could implement the procedure above without
touching standard durus :-).

- --
Jesus Cea Avion                         _/_/      _/_/_/        _/_/_/
jcea@argo.es http://www.argo.es/~jcea/ _/_/    _/_/  _/_/    _/_/  _/_/
jabber / xmpp:jcea@jabber.org         _/_/    _/_/          _/_/_/_/_/
                               _/_/  _/_/    _/_/          _/_/  _/_/
"Things are not so easy"      _/_/  _/_/    _/_/  _/_/    _/_/  _/_/
"My name is Dump, Core Dump"   _/_/_/        _/_/_/      _/_/  _/_/
"El amor es poner tu felicidad en la felicidad de otro" - Leibniz
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2.2 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iQCVAwUBRGlBE5lgi5GaxT1NAQLsiQP+OP18I9bLSsi5lN3jABCLL6ZVbZgpejld
XSRCkRmZisbwMdIJbafOMeQ76QvqZR7Xy318C53bJ/3ITni3QeE77cBKBJl1axkO
tGkXOtTU6CUXnfYhpEHSMfCWcqzFbe5VRoTjx/i9vJxhVjfPpzMZU5em4VM3Xtml
kAwN6a3Zq80=
=EGxo
-----END PGP SIGNATURE-----
reply