ITS#8307 fix slapo-accesslog: noop if logDB isn't open yet

Add be_flag for DB OPEN status
This commit is contained in:
Howard Chu 2021-01-13 16:35:43 +00:00
parent efaf9a4a17
commit eefe12366c
3 changed files with 12 additions and 0 deletions

View File

@ -226,6 +226,7 @@ int backend_startup_one(Backend *be, ConfigReply *cr)
rc = be->bd_info->bi_db_open( be, cr );
if ( rc == 0 ) {
(void)backend_set_controls( be );
be->be_flags |= SLAP_DBFLAG_OPEN;
} else {
char *type = be->bd_info->bi_type;
@ -291,6 +292,7 @@ int backend_startup(Backend *be)
rc );
return rc;
}
frontendDB->be_flags |= SLAP_DBFLAG_OPEN;
}
/* open each backend type */
@ -365,6 +367,7 @@ int backend_shutdown( Backend *be )
if ( be->bd_info->bi_db_close ) {
rc = be->bd_info->bi_db_close( be, NULL );
be->be_flags &= ~SLAP_DBFLAG_OPEN;
if ( rc ) return rc;
}
@ -382,6 +385,7 @@ int backend_shutdown( Backend *be )
continue;
if ( be->bd_info->bi_db_close ) {
be->bd_info->bi_db_close( be, NULL );
be->be_flags &= ~SLAP_DBFLAG_OPEN;
}
if(rc != 0) {
@ -406,6 +410,7 @@ int backend_shutdown( Backend *be )
/* close frontend, if required */
if ( frontendDB->bd_info->bi_db_close ) {
rc = frontendDB->bd_info->bi_db_close ( frontendDB, NULL );
frontendDB->be_flags &= ~SLAP_DBFLAG_OPEN;
if ( rc != 0 ) {
Debug( LDAP_DEBUG_ANY,
"backend_startup: bi_db_close(frontend) failed! (%d)\n",
@ -655,6 +660,7 @@ be_db_close( void )
LDAP_STAILQ_FOREACH( be, &backendDB, be_next ) {
if ( be->bd_info->bi_db_close ) {
be->bd_info->bi_db_close( be, NULL );
be->be_flags &= ~SLAP_DBFLAG_OPEN;
}
}

View File

@ -1501,6 +1501,10 @@ static int accesslog_response(Operation *op, SlapReply *rs) {
if ( rs->sr_type != REP_RESULT && rs->sr_type != REP_EXTENDED )
return SLAP_CB_CONTINUE;
/* can't do anything if logDB isn't open */
if ( !SLAP_DBOPEN( li->li_db ))
return SLAP_CB_CONTINUE;
logop = accesslog_op2logop( op );
lo = logops+logop+EN_OFFSET;
if ( !( li->li_ops & lo->mask )) {

View File

@ -1872,6 +1872,7 @@ struct BackendDB {
#define SLAP_DBFLAG_MULTI_SHADOW 0x80000U /* uses multi-provider */
#define SLAP_DBFLAG_DISABLED 0x100000U
#define SLAP_DBFLAG_LASTBIND 0x200000U
#define SLAP_DBFLAG_OPEN 0x400000U /* db is currently open */
slap_mask_t be_flags;
#define SLAP_DBFLAGS(be) ((be)->be_flags)
#define SLAP_NOLASTMOD(be) (SLAP_DBFLAGS(be) & SLAP_DBFLAG_NOLASTMOD)
@ -1899,6 +1900,7 @@ struct BackendDB {
#define SLAP_SINGLE_SHADOW(be) (SLAP_DBFLAGS(be) & SLAP_DBFLAG_SINGLE_SHADOW)
#define SLAP_MULTIPROVIDER(be) (SLAP_DBFLAGS(be) & SLAP_DBFLAG_MULTI_SHADOW)
#define SLAP_DBCLEAN(be) (SLAP_DBFLAGS(be) & SLAP_DBFLAG_CLEAN)
#define SLAP_DBOPEN(be) (SLAP_DBFLAGS(be) & SLAP_DBFLAG_OPEN)
#define SLAP_DBACL_ADD(be) (SLAP_DBFLAGS(be) & SLAP_DBFLAG_ACL_ADD)
#define SLAP_SYNC_SUBENTRY(be) (SLAP_DBFLAGS(be) & SLAP_DBFLAG_SYNC_SUBENTRY)