From: Howard Chu Date: Sat, 25 Oct 2003 22:07:31 +0000 (+0000) Subject: Fix retry on failure X-Git-Tag: OPENLDAP_REL_ENG_2_1_MP~478 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=5ed0318b792e2b2cb8ca5c0671fdce4eedffa872;p=openldap Fix retry on failure --- diff --git a/servers/slapd/connection.c b/servers/slapd/connection.c index cf46ed3160..90c8f3406b 100644 --- a/servers/slapd/connection.c +++ b/servers/slapd/connection.c @@ -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) diff --git a/servers/slapd/syncrepl.c b/servers/slapd/syncrepl.c index 1ef88a66e6..c3bf11a14e 100644 --- a/servers/slapd/syncrepl.c +++ b/servers/slapd/syncrepl.c @@ -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;