ITS#8849 Introduce (un)pause callbacks to backends

This commit is contained in:
Ondřej Kuzník 2018-05-09 15:02:34 +01:00
parent 0f4d656a57
commit f4e824c8da
2 changed files with 39 additions and 2 deletions

View file

@ -3270,13 +3270,46 @@ slap_sig_wake( int sig )
int
slap_pause_server( void )
{
return ldap_pvt_thread_pool_pause( &connection_pool );
BackendInfo *bi;
int rc = LDAP_SUCCESS;
rc = ldap_pvt_thread_pool_pause( &connection_pool );
LDAP_STAILQ_FOREACH(bi, &backendInfo, bi_next) {
if ( bi->bi_pause ) {
rc = bi->bi_pause( bi );
if ( rc != LDAP_SUCCESS ) {
Debug( LDAP_DEBUG_ANY, "slap_pause_server: "
"bi_pause failed for backend %s\n",
bi->bi_type, 0, 0 );
return rc;
}
}
}
return rc;
}
int
slap_unpause_server( void )
{
return ldap_pvt_thread_pool_resume( &connection_pool );
BackendInfo *bi;
int rc = LDAP_SUCCESS;
LDAP_STAILQ_FOREACH(bi, &backendInfo, bi_next) {
if ( bi->bi_unpause ) {
rc = bi->bi_unpause( bi );
if ( rc != LDAP_SUCCESS ) {
Debug( LDAP_DEBUG_ANY, "slap_unpause_server: "
"bi_unpause failed for backend %s\n",
bi->bi_type, 0, 0 );
return rc;
}
}
}
rc = ldap_pvt_thread_pool_resume( &connection_pool );
return rc;
}

View file

@ -1992,6 +1992,8 @@ struct BackendDB {
typedef int (BI_bi_func) LDAP_P((BackendInfo *bi));
typedef BI_bi_func BI_init;
typedef BI_bi_func BI_open;
typedef BI_bi_func BI_pause;
typedef BI_bi_func BI_unpause;
typedef BI_bi_func BI_close;
typedef BI_bi_func BI_destroy;
typedef int (BI_config) LDAP_P((BackendInfo *bi,
@ -2251,6 +2253,8 @@ struct BackendInfo {
BI_init *bi_init;
BI_config *bi_config;
BI_open *bi_open;
BI_pause *bi_pause;
BI_unpause *bi_unpause;
BI_close *bi_close;
BI_destroy *bi_destroy;