]> git.sur5r.net Git - openldap/blobdiff - libraries/libldap/abandon.c
ITS#7694 Fix use of IPv6 with LDAP_CONNECTIONLESS
[openldap] / libraries / libldap / abandon.c
index 36f61f32984e982266bcc16f425bb3524df0c8fc..8fd9bc25874f1c1b53f0832cc4557755a289d5b3 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2012 The OpenLDAP Foundation.
+ * Copyright 1998-2013 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -209,7 +209,7 @@ start_again:;
                        LDAP_NEXT_MSGID(ld, i);
 #ifdef LDAP_CONNECTIONLESS
                        if ( LDAP_IS_UDP(ld) ) {
-                               struct sockaddr sa = {0};
+                               struct sockaddr_storage sa = {0};
                                /* dummy, filled with ldo_peer in request.c */
                                err = ber_write( ber, (char *) &sa, sizeof(sa), 0 );
                        }
@@ -279,9 +279,14 @@ start_again:;
 
        if ( lr != NULL ) {
                if ( sendabandon || lr->lr_status == LDAP_REQST_WRITING ) {
+                       /* release ld_req_mutex while grabbing ld_conn_mutex to
+                        * prevent deadlock.
+                        */
+                       LDAP_MUTEX_UNLOCK( &ld->ld_req_mutex );
                        LDAP_MUTEX_LOCK( &ld->ld_conn_mutex );
                        ldap_free_connection( ld, lr->lr_conn, 0, 1 );
                        LDAP_MUTEX_UNLOCK( &ld->ld_conn_mutex );
+                       LDAP_MUTEX_LOCK( &ld->ld_req_mutex );
                }
 
                if ( origid == msgid ) {