From 838a7f513853ba213f1a25d19b3a4cfe27ace174 Mon Sep 17 00:00:00 2001 From: Ondrej Kuznik Date: Mon, 9 Apr 2012 17:35:41 +0200 Subject: [PATCH] ITS#7182 allow for later monitor subsystem registration Some databases might want to register their subsystems under the dn allocated for them by monitor_register_databas. It requires that the deferred database registration callback be called *before* the subsystem's. --- servers/slapd/back-ldap/monitor.c | 4 +- servers/slapd/back-monitor/back-monitor.h | 1 + servers/slapd/back-monitor/init.c | 46 +++++++++++++++++++ .../slapd/back-monitor/proto-back-monitor.h | 3 ++ 4 files changed, 52 insertions(+), 2 deletions(-) diff --git a/servers/slapd/back-ldap/monitor.c b/servers/slapd/back-ldap/monitor.c index 456c14a418..35e19c4d58 100644 --- a/servers/slapd/back-ldap/monitor.c +++ b/servers/slapd/back-ldap/monitor.c @@ -994,7 +994,7 @@ ldap_back_monitor_db_open( BackendDB *be ) mss->mss_open = ldap_back_monitor_conn_init; mss->mss_private = li; - if ( mbe->register_subsys( mss ) ) + if ( mbe->register_subsys_late( mss ) ) { Debug( LDAP_DEBUG_ANY, "ldap_back_monitor_db_open: " @@ -1009,7 +1009,7 @@ ldap_back_monitor_db_open( BackendDB *be ) mss->mss_open = ldap_back_monitor_ops_init; mss->mss_private = li; - if ( mbe->register_subsys( mss ) ) + if ( mbe->register_subsys_late( mss ) ) { Debug( LDAP_DEBUG_ANY, "ldap_back_monitor_db_open: " diff --git a/servers/slapd/back-monitor/back-monitor.h b/servers/slapd/back-monitor/back-monitor.h index 7a5674c618..50073d719c 100644 --- a/servers/slapd/back-monitor/back-monitor.h +++ b/servers/slapd/back-monitor/back-monitor.h @@ -290,6 +290,7 @@ typedef struct monitor_extra_t { monitor_subsys_t * (*get_subsys_by_dn)( struct berval *ndn, int sub ); int (*register_subsys)( monitor_subsys_t *ms ); + int (*register_subsys_late)( monitor_subsys_t *ms ); int (*register_backend)( BackendInfo *bi ); int (*register_database)( BackendDB *be, struct berval *ndn_out ); int (*register_overlay_info)( slap_overinst *on ); diff --git a/servers/slapd/back-monitor/init.c b/servers/slapd/back-monitor/init.c index 458f0bc439..59eedcbbd3 100644 --- a/servers/slapd/back-monitor/init.c +++ b/servers/slapd/back-monitor/init.c @@ -52,6 +52,7 @@ static const monitor_extra_t monitor_extra = { monitor_back_get_subsys_by_dn, monitor_back_register_subsys, + monitor_back_register_subsys_late, monitor_back_register_backend, monitor_back_register_database, monitor_back_register_overlay_info, @@ -283,6 +284,7 @@ enum { LIMBO_DATABASE, LIMBO_OVERLAY_INFO, LIMBO_OVERLAY, + LIMBO_SUBSYS, LIMBO_LAST }; @@ -310,6 +312,46 @@ monitor_back_is_configured( void ) return be_monitor != NULL; } +int +monitor_back_register_subsys_late( + monitor_subsys_t *ms ) +{ + entry_limbo_t **elpp, el = { 0 }; + monitor_info_t *mi; + + if ( be_monitor == NULL ) { + Debug( LDAP_DEBUG_ANY, + "monitor_back_register_subsys_late: " + "monitor database not configured.\n", + 0, 0, 0 ); + return -1; + } + + /* everyting is ready, can register already */ + if ( monitor_subsys_is_opened() ) { + return monitor_back_register_subsys( ms ); + } + + mi = ( monitor_info_t * )be_monitor->be_private; + + + el.el_type = LIMBO_SUBSYS; + + el.el_mss = ms; + + for ( elpp = &mi->mi_entry_limbo; + *elpp; + elpp = &(*elpp)->el_next ) + /* go to last */; + + *elpp = (entry_limbo_t *)ch_malloc( sizeof( entry_limbo_t ) ); + + el.el_next = NULL; + **elpp = el; + + return 0; +} + int monitor_back_register_backend( BackendInfo *bi ) @@ -2440,6 +2482,10 @@ monitor_back_db_open( rc = monitor_back_register_overlay( el->el_be, el->el_on, el->el_ndn ); break; + case LIMBO_SUBSYS: + rc = monitor_back_register_subsys( el->el_mss ); + break; + default: assert( 0 ); } diff --git a/servers/slapd/back-monitor/proto-back-monitor.h b/servers/slapd/back-monitor/proto-back-monitor.h index 143d917eb9..86895cc3b5 100644 --- a/servers/slapd/back-monitor/proto-back-monitor.h +++ b/servers/slapd/back-monitor/proto-back-monitor.h @@ -149,6 +149,9 @@ extern int monitor_back_register_subsys LDAP_P(( monitor_subsys_t *ms )); extern int +monitor_back_register_subsys_late LDAP_P(( + monitor_subsys_t *ms )); +extern int monitor_back_register_backend LDAP_P(( BackendInfo *bi )); extern int -- 2.39.5