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

(ITS#5939) Missing close of file descriptor

Full_Name: Joakim Bentholm
Version: OpenLDAP 2.4.13
OS: FreeBSD 7.0 Release
URL: ftp://ftp.openldap.org/incoming/
Submission from: (NULL) (

The running setup:
An ldap server with a socket back-end communicating with server process
listening on incoming requests from the socket back-end and replying in an
orderly fashing.

The failure:
If the server process shuts down, the socket back-end will continue to try to
connect and allocating new file descriptors which will never be released. If the
server process  is restarted everything will work, unless the file descriptor
limit have been reached, in case the ldap server have to be restart.

Solution: close the file descripton
The following patch solves the problem
--- servers/slapd/back-sock/opensock.c.orig     2008-02-09 01:46:09.000000000
+++ servers/slapd/back-sock/opensock.c  2009-02-02 16:09:24.000000000 +0100
@@ -57,6 +57,7 @@
        if ( connect( fd, (struct sockaddr *)&sockun, sizeof(sockun) ) < 0 ) {
                Debug( LDAP_DEBUG_ANY, "socket connect(%s) failed\n",
                        sockpath ? sockpath : "<null>", 0, 0 );
+               close( fd );
                return( NULL );