]> git.sur5r.net Git - openldap/commitdiff
ITS#7182 allow for later monitor subsystem registration
authorOndrej Kuznik <ondrej.kuznik@acision.com>
Mon, 9 Apr 2012 15:35:41 +0000 (17:35 +0200)
committerHoward Chu <hyc@openldap.org>
Wed, 18 Apr 2012 18:44:17 +0000 (11:44 -0700)
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
servers/slapd/back-monitor/back-monitor.h
servers/slapd/back-monitor/init.c
servers/slapd/back-monitor/proto-back-monitor.h

index 456c14a418b2599a728ddeec2f8e4fb6f30ca1ca..35e19c4d5816e2c1f4c49864ca8e384ede1dd295 100644 (file)
@@ -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: "
index 7a5674c618748e7ea536e92fa30742c8c01ce33b..50073d719c3f5378eec858a0a05df8f8261185d7 100644 (file)
@@ -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 );
index 458f0bc439984470afe0d66666a9b9a6e2b2a463..59eedcbbd3431932c1388c535d2c030fc6bc977b 100644 (file)
@@ -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 );
                        }
index 143d917eb99cc83f8bf5e96a79cc2d084256040e..86895cc3b54a17b42aa950f2e8534a5c04e0482e 100644 (file)
@@ -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