]> git.tuebingen.mpg.de Git - paraslash.git/commit
server: Fix assignment of afs_pid.
authorAndre Noll <maan@systemlinux.org>
Thu, 5 Nov 2009 23:21:16 +0000 (00:21 +0100)
committerAndre Noll <maan@systemlinux.org>
Thu, 5 Nov 2009 23:21:16 +0000 (00:21 +0100)
commit06c82519ac27d0c34e1b6e0c1a1f088fe34e61b3
treedd198bda899188f93cb4a85b8a4cb35c1bdd1971
parent2ce63f32adf9c47d6ed9604f3cd090229409df05
server: Fix assignment of afs_pid.

glibc-2.11 revealed the following bug in init_afs(): The assignment

mmd->afs_pid = fork();

results in undefined behaviour because fork() returns twice and mmd->afs_pid lives
in a shared memory area. Depending on whether the child runs first, this results in
mmd->afs_pid being either zero or the pid of the afs child process.

mmd->afs_pid being zero seems to happen always with glibc-2.11 and has rather
strange consequences:

First,  it causes para_server attempt to kill process 0 instead of the afs process on
exit. This fails because para_server never runs as root.  However, it may result in dirty
osl tables as the afs process might access mmd after the shared memory area containing
mmd has already been destroyed.

Second,  para_server fails to notice the death of the afs process, which is really bad and
may cause tons of error messages being written to the log.

Fix this bug by temporarily storing the afs pid in a local variable and setting mmd->afs_pid
only in the server (parent) process.
server.c