]> git.sur5r.net Git - openldap/commitdiff
little more about potential concurrency issues
authorPierangelo Masarati <ando@openldap.org>
Wed, 3 Aug 2005 16:54:08 +0000 (16:54 +0000)
committerPierangelo Masarati <ando@openldap.org>
Wed, 3 Aug 2005 16:54:08 +0000 (16:54 +0000)
libraries/libldap/request.c
libraries/libldap/result.c

index 12fc3af44767d78f19861bb1624cab1827e6a411..7e352fa23ed6a4f9e628ee9d1dec2ffe8caac613 100644 (file)
@@ -491,8 +491,10 @@ ldap_free_connection( LDAP *ld, LDAPConn *lc, int force, int unbind )
                ldap_int_sasl_close( ld, lc );
 
                prevlc = NULL;
-               for ( tmplc = ld->ld_conns; tmplc != NULL;
-                   tmplc = tmplc->lconn_next ) {
+               for ( tmplc = ld->ld_conns;
+                       tmplc != NULL;
+                       tmplc = tmplc->lconn_next )
+               {
                        if ( tmplc == lc ) {
                                if ( prevlc == NULL ) {
                                    ld->ld_conns = tmplc->lconn_next;
@@ -514,9 +516,6 @@ ldap_free_connection( LDAP *ld, LDAPConn *lc, int force, int unbind )
                if ( force ) {
                        LDAPRequest     *lr;
 
-#ifdef LDAP_R_COMPILE
-                       ldap_pvt_thread_mutex_lock( &ld->ld_req_mutex );
-#endif
                        for ( lr = ld->ld_requests; lr; ) {
                                LDAPRequest     *lr_next = lr->lr_next;
 
@@ -526,9 +525,6 @@ ldap_free_connection( LDAP *ld, LDAPConn *lc, int force, int unbind )
 
                                lr = lr_next;
                        }
-#ifdef LDAP_R_COMPILE
-                       ldap_pvt_thread_mutex_unlock( &ld->ld_req_mutex );
-#endif
                }
                if ( lc->lconn_sb != ld->ld_sb ) {
                        ber_sockbuf_free( lc->lconn_sb );
index cbb744d88291511154214d435455a38dae95b650..56eb3291c3c8038ba7f43d4448f7a5fae3d1e004 100644 (file)
@@ -749,7 +749,13 @@ lr->lr_res_matched ? lr->lr_res_matched : "" );
                        }
 
                        if ( lc != NULL ) {
+#ifdef LDAP_R_COMPILE
+                               ldap_pvt_thread_mutex_lock( &ld->ld_req_mutex );
+#endif
                                ldap_free_connection( ld, lc, 0, 1 );
+#ifdef LDAP_R_COMPILE
+                               ldap_pvt_thread_mutex_unlock( &ld->ld_req_mutex );
+#endif
                                *lcp = NULL;
                        }
                }