-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

On 11.09.2011 18:19, Robert Kawecki wrote:
> ZNC uses an exclusive lock on a file handle that is open read-only. This
> operation is not supported on NFSv4, as described here:
> http://www.spinics.net/lists/linux-nfs/msg18594.html
> This problem makes znc unusable on NFSv4-mounted home directories, resulting 
> in
> error message:
> [ !! ]is already running on this config. ]
> (since it can't lock the file, it assumes someone else did!)
> 
> Relevant output of "strace -e open,flock znc":
> open("/home/users/thewanderer/.znc/configs/znc.conf", O_RDONLY) = 3
> flock(3, LOCK_EX|LOCK_NB)               = -1 EIO (Input/output error)

Hi,

Welcome to the wonderful world that is file locks. To quote "man 2 flock":

   A shared or exclusive lock can be placed on a file regardless of the mode in
   which the file was opened.

So technically a NFS bug, if you ask me.

> I see two solutions:
> 0) Implement proper error checking when locking the config file. EIO is not
> equal to EWOULDBLOCK!

How would that help? Instead of "znc is already running on this config", startup
would fail with "Could not lock config".

> 1) Use a writable file, like znc.conf.lock  (config file path with ".lock"
> suffix appended), for exclusive locks.

(Just znc.conf is fine, too, since ZNC rewrites its config regularly and thus
needs write access to it anyway)

Since SVN rev 2065 / git commit 33ce80f476be797a / ZNC 0.094, ZNC uses fcntl()
instead of flock() for file locks. This change was done for Solaris, but AFAIK
this should also make NFS happy.

Relevant strace output:
write(1, "\33[1m\33[34m[\33[32m    \33[34m]\33[39m\33["..., 92[    ] Opening
Config [/home/psychon/.znc/configs/znc.conf]... ) = 92
stat("/home/psychon/.znc/configs/znc.conf", {st_mode=S_IFREG|0600, st_size=2098,
...}) = 0
stat("/home/psychon/.znc/configs/znc.conf", {st_mode=S_IFREG|0600, st_size=2098,
...}) = 0
open("/home/psychon/.znc/configs/znc.conf", O_RDWR) = 3
fcntl(3, F_GETFD)                       = 0
fcntl(3, F_SETFD, FD_CLOEXEC)           = 0
fcntl(3, F_SETLK, {type=F_WRLCK, whence=SEEK_SET, start=0, len=0}) = 0
lseek(3, 0, SEEK_SET)                   = 0
read(3, "// WARNING\n//\n// Do NOT edit thi"..., 4096) = 2098
read(3, "", 4096)                       = 0

Cheers,
Uli
- -- 
"Do you know that books smell like nutmeg or some spice from a foreign land?"
                                                  -- Faber in Fahrenheit 451
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)

iQEcBAEBCAAGBQJObPqRAAoJECLkKOvLj8sGno4H/2VAbmpB5JN06pVrqhIodfwN
EfDpKQd3PSn9gdNMPkxhEnAL3wr+7YrG8dwuj5uUZAJAfv12Y3F0MvV85oMPdf+i
+oOtfmvXOOyQxYF/Hf78J5SdAJamVPQFPSSRhIp7R+r7KNTwhw5kRE7Am033qmPG
ilbvC3IT36rljLnevOXOUyRdncOusOjya1tk1zMdOYftxfGRGG7ViPwjLQO9Ty+1
tjxyRtPZgjUFqhZTCtEGrmcwpp35Y2fNHlY8eqjCNssqNSGdy7ifk3bc1+zGbxXR
xMkEO4O8hG9b9CYOcUys9lOuFj92hXF3TUrFIHp6UWWzFTvoATeFFLduXDswm9M=
=8TQh
-----END PGP SIGNATURE-----



-- 
To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org

Reply via email to