]> git.sur5r.net Git - openldap/commitdiff
Fix retry on failure
authorHoward Chu <hyc@openldap.org>
Sat, 25 Oct 2003 22:07:31 +0000 (22:07 +0000)
committerHoward Chu <hyc@openldap.org>
Sat, 25 Oct 2003 22:07:31 +0000 (22:07 +0000)
servers/slapd/connection.c
servers/slapd/syncrepl.c

index cf46ed31607e7e46d742f7b8a2fe9a19a6cb4cb4..90c8f3406bfd69f5acdd44d892356820b6f19b5a 100644 (file)
@@ -1180,7 +1180,7 @@ void connection_client_stop(
        c->c_conn_state = SLAP_C_INVALID;
        c->c_struct_state = SLAP_C_UNUSED;
        connection_return( c );
-       slapd_remove( s, 0, 0 );
+       slapd_remove( s, 0, 1 );
 }
 
 int connection_read(ber_socket_t s)
index 1ef88a66e6f0a41b378f64f1cf28e1510394d9ee..c3bf11a14e51f625ef29e991b43e78352c81d95d 100644 (file)
@@ -586,11 +586,10 @@ do_syncrep2(
        }
 
        if ( rc == -1 ) {
-               int errno;
                const char *errstr;
 
-               ldap_get_option( si->si_ld, LDAP_OPT_ERROR_NUMBER, &errno );
-               errstr = ldap_err2string( errno );
+               ldap_get_option( si->si_ld, LDAP_OPT_ERROR_NUMBER, &rc );
+               errstr = ldap_err2string( rc );
                
 #ifdef NEW_LOGGING
                LDAP_LOG( OPERATION, ERR,
@@ -607,9 +606,6 @@ done:
        if ( rc && si->si_ld ) {
                ldap_unbind( si->si_ld );
                si->si_ld = NULL;
-               /* just close and report success */
-               if ( rc == -2 )
-                       rc = 0;
        }
 
        return rc;
@@ -626,6 +622,8 @@ do_syncrepl(
        Operation op = {0};
        int rc = LDAP_SUCCESS;
        int first = 0;
+       int dostop = 0;
+       ber_socket_t s;
 
 #ifdef NEW_LOGGING
        LDAP_LOG ( OPERATION, DETAIL1, "do_syncrepl\n", 0, 0, 0 );
@@ -644,6 +642,14 @@ do_syncrepl(
                return NULL;
        }
 
+       if ( slapd_abrupt_shutdown && si->si_ld ) {
+               ldap_get_option( si->si_ld, LDAP_OPT_DESC, &s );
+               connection_client_stop( s );
+               ldap_unbind( si->si_ld );
+               si->si_ld = NULL;
+               return NULL;
+       }
+
        conn.c_connid = -1;
        conn.c_send_ldap_result = slap_send_ldap_result;
        conn.c_send_search_entry = slap_send_search_entry;
@@ -673,7 +679,6 @@ do_syncrepl(
 
        /* Process results */
        if ( rc == LDAP_SUCCESS ) {
-               ber_socket_t s;
                ldap_get_option( si->si_ld, LDAP_OPT_DESC, &s );
 
                rc = do_syncrep2( &op, si );
@@ -690,7 +695,7 @@ do_syncrepl(
                                        connection_client_enable( s );
                                }
                        } else {
-                               connection_client_stop( s );
+                               dostop = 1;
                        }
                } else {
                        ch_free( si->si_syncCookie.bv_val );
@@ -710,15 +715,21 @@ do_syncrepl(
                ldap_pvt_runqueue_stoptask( &syncrepl_rq, rtask );
        }
 
+       if ( dostop ) {
+               connection_client_stop( s );
+       }
+
        if ( rc && rc != LDAP_SERVER_DOWN ) {
                ldap_pvt_runqueue_remove( &syncrepl_rq, rtask );
-       } else if ( rc == LDAP_SERVER_DOWN ||
-               si->si_type == LDAP_SYNC_REFRESH_ONLY ) {
-               rc = 0;
        } else {
-               rc = 1;
+               if ( rc == LDAP_SERVER_DOWN ||
+                       si->si_type == LDAP_SYNC_REFRESH_ONLY ) {
+                       rc = 0;
+               } else {
+                       rc = 1;
+               }
+               ldap_pvt_runqueue_resched( &syncrepl_rq, rtask, rc );
        }
-       ldap_pvt_runqueue_resched( &syncrepl_rq, rtask, rc );
        ldap_pvt_thread_mutex_unlock( &syncrepl_rq.rq_mutex );
 
        return NULL;