]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/syncrepl.c
Import ITS#4158 fixes from HEAD
[openldap] / servers / slapd / syncrepl.c
index dfe9a2fbce9ac0cecc0e71b99f4db4c43f36110e..fbdf1d86fc6183c89fa7a1b11ddc7317bc8d0d3b 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 2003-2004 The OpenLDAP Foundation.
+ * Copyright 2003-2005 The OpenLDAP Foundation.
  * Portions Copyright 2003 by IBM Corporation.
  * Portions Copyright 2003 by Howard Chu, Symas Corporation.
  * All rights reserved.
@@ -306,7 +306,7 @@ do_syncrep1(
 
                        /* FIXME (see above comment) */
                        /* if Kerberos credentials cache is not active, retry */
-                       if ( strcmp( si->si_saslmech, "GSSAPI" ) == 0 &&
+                       if ( si->si_saslmech && !strcmp( si->si_saslmech, "GSSAPI" ) &&
                                rc == LDAP_LOCAL_ERROR )
                        {
                                rc = LDAP_SERVER_DOWN;
@@ -543,6 +543,10 @@ do_syncrep2(
                  msg != NULL;
                  msg = ldap_next_message( si->si_ld, msg ) )
                {
+                       if ( slapd_shutdown ) {
+                               rc = -2;
+                               goto done;
+                       }
                        switch( ldap_msgtype( msg ) ) {
                        case LDAP_RES_SEARCH_ENTRY:
                                ldap_get_entry_controls( si->si_ld, msg, &rctrls );
@@ -860,11 +864,14 @@ do_syncrepl(
        if ( si == NULL )
                return NULL;
 
+       ldap_pvt_thread_mutex_lock( &si->si_mutex );
+
        switch( abs( si->si_type )) {
        case LDAP_SYNC_REFRESH_ONLY:
        case LDAP_SYNC_REFRESH_AND_PERSIST:
                break;
        default:
+               ldap_pvt_thread_mutex_unlock( &si->si_mutex );
                return NULL;
        }
 
@@ -875,6 +882,7 @@ do_syncrepl(
                        ldap_unbind( si->si_ld );
                        si->si_ld = NULL;
                }
+               ldap_pvt_thread_mutex_unlock( &si->si_mutex );
                return NULL;
        }
 
@@ -976,6 +984,7 @@ do_syncrepl(
        }
        
        ldap_pvt_thread_mutex_unlock( &syncrepl_rq.rq_mutex );
+       ldap_pvt_thread_mutex_unlock( &si->si_mutex );
 
        return NULL;
 }
@@ -2356,6 +2365,7 @@ avl_ber_bvfree( void *bv )
 void
 syncinfo_free( syncinfo_t *sie )
 {
+       ldap_pvt_thread_mutex_destroy( &sie->si_mutex );
        if ( sie->si_provideruri ) {
                ch_free( sie->si_provideruri );
        }