andykimpe / rpms / 389-ds-base

Forked from rpms/389-ds-base 5 months ago
Clone
Blob Blame History Raw
From ef6e05286dbd4df3bc20cee51b1769496612a7af Mon Sep 17 00:00:00 2001
From: Matthew Via <​matthew.via@mailtrust.com>
Date: Wed, 10 Jul 2013 11:30:57 -0600
Subject: [PATCH 81/99] Ticket #47428 - Memory leak in 389-ds-base 1.2.11.15

https://fedorahosted.org/389/ticket/47428
Reviewed by: rmeggins
Branch: 389-ds-base-1.2.11
Fix Description: Call ber_sockbuf_remove_io to remove our openldap io layer
from the connection c_sb and free the data associated with it.
Platforms tested: RHEL6 x86_64
Flag Day: no
Doc impact: no
(cherry picked from commit df93b03da12c22d18a4153105f687671e52efdd5)
(cherry picked from commit ed26da0722a23a50fb286e8bc57ec4fea8dde4a2)
(cherry picked from commit b18ee0b41fbcc901ed2a9b5c0431708e452a40c6)
(cherry picked from commit 6e0a8efb16a1651387623ce997c021f0460d2788)
---
 ldap/servers/slapd/connection.c | 1 +
 ldap/servers/slapd/daemon.c     | 7 +++++++
 ldap/servers/slapd/proto-slap.h | 1 +
 3 files changed, 9 insertions(+)

diff --git a/ldap/servers/slapd/connection.c b/ldap/servers/slapd/connection.c
index 1d1adac..914a2d3 100644
--- a/ldap/servers/slapd/connection.c
+++ b/ldap/servers/slapd/connection.c
@@ -203,6 +203,7 @@ connection_cleanup(Connection *conn)
 	/* destroy any sasl context */
 	sasl_dispose((sasl_conn_t**)&conn->c_sasl_conn);
 	/* PAGED_RESULTS */
+	handle_closed_connection(conn);  /* Clean up sockbufs */
 	pagedresults_cleanup(conn, 0 /* do not need to lock inside */);
 
 	/* free the connection socket buffer */
diff --git a/ldap/servers/slapd/daemon.c b/ldap/servers/slapd/daemon.c
index c67067b..8f147f1 100644
--- a/ldap/servers/slapd/daemon.c
+++ b/ldap/servers/slapd/daemon.c
@@ -2590,6 +2590,13 @@ bail:
 #endif /* ENABLE_AUTOBIND */
 #endif /* ENABLE_LDAPI */
 
+void
+handle_closed_connection(Connection *conn)
+{
+	ber_sockbuf_remove_io(conn->c_sb, &openldap_sockbuf_io,
+		LBER_SBIOD_LEVEL_PROVIDER);
+}
+
 /* NOTE: this routine is not reentrant */
 static int
 handle_new_connection(Connection_Table *ct, int tcps, PRFileDesc *pr_acceptfd, int secure, int local)
diff --git a/ldap/servers/slapd/proto-slap.h b/ldap/servers/slapd/proto-slap.h
index a15c0cc..d4c9ab6 100644
--- a/ldap/servers/slapd/proto-slap.h
+++ b/ldap/servers/slapd/proto-slap.h
@@ -1379,6 +1379,7 @@ int sasl_io_setup(Connection *c);
 /*
  * daemon.c
  */
+void handle_closed_connection(Connection *);
 #ifndef LINUX
 void slapd_do_nothing(int);
 #endif
-- 
1.8.1.4