File autofs-5.0.8-serialize-libldap-unbind.patch of Package autofs.openSUSE_13.1_Update

Similar to upstream commit 9fc20db13b2e9f2c7613ef7fb226280543eb85ea, but this
time to serialize LDAP unbinds.

Reference: bnc#853469

Index: autofs-5.0.8/modules/lookup_ldap.c
===================================================================
--- autofs-5.0.8.orig/modules/lookup_ldap.c
+++ autofs-5.0.8/modules/lookup_ldap.c
@@ -203,7 +203,7 @@ int bind_ldap_simple(unsigned logopt, LD
 	return 0;
 }
 
-int unbind_ldap_connection(unsigned logopt, LDAP *ldap, struct lookup_context *ctxt)
+int __unbind_ldap_connection(unsigned logopt, LDAP *ldap, struct lookup_context *ctxt)
 {
 	int rv;
 
@@ -220,6 +220,17 @@ int unbind_ldap_connection(unsigned logo
 	return rv;
 }
 
+int unbind_ldap_connection(unsigned logopt, LDAP *ldap, struct lookup_context *ctxt)
+{
+	int rv;
+
+	ldapinit_mutex_lock();
+	rv = __unbind_ldap_connection(logopt, ldap, ctxt);
+	ldapinit_mutex_unlock();
+
+	return rv;
+}
+
 LDAP *__init_ldap_connection(unsigned logopt, const char *uri, struct lookup_context *ctxt)
 {
 	LDAP *ldap = NULL;
@@ -280,7 +291,7 @@ LDAP *__init_ldap_connection(unsigned lo
 
 		rv = ldap_start_tls_s(ldap, NULL, NULL);
 		if (rv != LDAP_SUCCESS) {
-			unbind_ldap_connection(logopt, ldap, ctxt);
+			__unbind_ldap_connection(logopt, ldap, ctxt);
 			if (ctxt->tls_required) {
 				error(logopt, MODPREFIX
 				      "TLS required but START_TLS failed: %s",
openSUSE Build Service is sponsored by