Hallvard Breien Furuseth wrote:
On 02/05/2018 18:05, hyc@openldap.org wrote:
Following on from ITS#8505. mdb_env_close0() uses env->me_pid when clearing the readers table. If the env was open in a process that forked, and the child process calls mdb_env_close(), it will be clearing the wrong PID. Change this to use getpid() instead.
Wait, what? The child didn't write any pids to the table. If there are pids for it to clear, something is wrong. That can be:
No, there most likely aren't PIDs for it to clear. But most importantly, it must not clear using env->me_pid since that is still the parent's PID.
- The pid is from an older run, and the system reused the pid. If we code for this, it should be to clear such pids during mdb_env_open. It gets very arbitrary to clear them when the user does env_close() in the child and the child happens to have the that reused pid.
No. If the system reused the PID then that means the previous owner of that PID is dead already anyway. If there are any table entries under that PID there's no problem removing them.
- The child opened a new MDB_env with the same path, and closes the parent's env afterwards. Don't Do That, users. But what to do in this situation, if we are to have code for it, is to do nothing with the lockfile. Not close it either, since closing it will lose the lock for the env which was opened in the child.
That's a completely different case. This ITS is specifically about a process with an open environment that subsequently forks.