From: Jong Hyuk Choi Date: Wed, 17 Sep 2003 10:34:10 +0000 (+0000) Subject: fix for persistent search termination (ITS#2724) X-Git-Tag: OPENLDAP_REL_ENG_2_1_MP~712 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=537ccc3f5f13618daeb52c3dd32d44f3f82e8acc;p=openldap fix for persistent search termination (ITS#2724) - the consumer slapd did not terminate when the provider is alive - use a timeout in ldap_result() of syncrepl.c --- diff --git a/servers/slapd/daemon.c b/servers/slapd/daemon.c index 042fa24b01..d83974bece 100644 --- a/servers/slapd/daemon.c +++ b/servers/slapd/daemon.c @@ -68,6 +68,7 @@ do { if (w) tcp_write( wake_sds[1], "0", 1 ); } while(0) static #endif volatile sig_atomic_t slapd_shutdown = 0, slapd_gentle_shutdown = 0; +volatile sig_atomic_t slapd_abrupt_shutdown = 0; static struct slap_daemon { ldap_pvt_thread_mutex_t sd_mutex; @@ -1951,6 +1952,7 @@ slapd_daemon_task( slap_listeners = NULL; if( !slapd_gentle_shutdown ) { + slapd_abrupt_shutdown = 1; connections_shutdown(); } diff --git a/servers/slapd/proto-slap.h b/servers/slapd/proto-slap.h index 008a258941..47803caa77 100644 --- a/servers/slapd/proto-slap.h +++ b/servers/slapd/proto-slap.h @@ -382,6 +382,8 @@ LDAP_SLAPD_F (void) slapd_clr_write LDAP_P((ber_socket_t s, int wake)); LDAP_SLAPD_F (void) slapd_set_read LDAP_P((ber_socket_t s, int wake)); LDAP_SLAPD_F (void) slapd_clr_read LDAP_P((ber_socket_t s, int wake)); +LDAP_SLAPD_V (volatile sig_atomic_t) slapd_abrupt_shutdown; + /* * dn.c */ diff --git a/servers/slapd/syncrepl.c b/servers/slapd/syncrepl.c index 864557dc01..36a77183fc 100644 --- a/servers/slapd/syncrepl.c +++ b/servers/slapd/syncrepl.c @@ -209,6 +209,9 @@ do_syncrepl( const char *text; int match; + struct timeval *tout_p = NULL; + struct timeval tout = { 10, 0 }; + #ifdef NEW_LOGGING LDAP_LOG ( OPERATION, DETAIL1, "do_syncrepl\n", 0, 0, 0 ); #else @@ -444,7 +447,21 @@ do_syncrepl( return NULL; } - while (( rc = ldap_result( ld, LDAP_RES_ANY, LDAP_MSG_ONE, NULL, &res )) > 0 ) { + if ( abs(si->type) == LDAP_SYNC_REFRESH_AND_PERSIST ){ + tout_p = &tout; + } else { + tout_p = NULL; + } + + while (( rc = ldap_result( ld, LDAP_RES_ANY, LDAP_MSG_ONE, tout_p, &res )) >= 0 ) { + + if ( rc == 0 ) { + if ( slapd_abrupt_shutdown ) { + break; + } else { + continue; + } + } for ( msg = ldap_first_message( ld, res ); msg != NULL; @@ -630,6 +647,7 @@ done: if ( res ) ldap_msgfree( res ); + ldap_unbind( ld ); ldap_pvt_thread_mutex_lock( &syncrepl_rq.rq_mutex );