[Date Prev][Date Next] [Chronological] [Thread] [Top]

socket close race (ITS#2035)

Full_Name: Howard Chu
Version: 1.2.9
OS: OS/390
URL: ftp://ftp.openldap.org/incoming/
Submission from: (NULL) (
Submitted by: hyc

There is an odd race condition that can arise when closing a socket. The symptom
is that slapd is blocked trying to read from a descriptor after select reported
it to be readable. What has actually happened is that another thread has closed
the socket, and then invoked syslog() to log a diagnostic message. In this
particular case, openlog() failed to create a connected socket to the syslog
daemon, so every syslog() invocation results in a new Unix domain socket being
opened. The new socket gets the same descriptor number as the LDAP session that
was just closed.

This problem appeared because the syslog daemon wasn't running on the machine,
which caused openlog() to fail to open a persistent connection. When the syslog
level is set to zero, thus bypassing any calls to syslog(), the problem

I've entered this just for reference. I believe that adding a rdwr lock to
control access to the connection structure may prevent the problem from ever
arising; I have code for this but have never tested it. (any reads and writes
get a readlock on the conn, close gets a writelock.)