]> git.sur5r.net Git - openldap/commitdiff
allow adding of back-bdb with monitoring on (ITS#4789)
authorPierangelo Masarati <ando@openldap.org>
Wed, 21 Mar 2007 22:35:37 +0000 (22:35 +0000)
committerPierangelo Masarati <ando@openldap.org>
Wed, 21 Mar 2007 22:35:37 +0000 (22:35 +0000)
servers/slapd/back-bdb/monitor.c
servers/slapd/back-monitor/database.c
servers/slapd/back-monitor/init.c
servers/slapd/back-monitor/proto-back-monitor.h

index 9114fac70b8ade71f5b883173f4b6eb4ddca6251..603a4ea03bf1ff82c62d390debd0f593c6f84b6c 100644 (file)
@@ -455,6 +455,8 @@ bdb_monitor_db_open( BackendDB *be )
        cb->mc_free = bdb_monitor_free;
        cb->mc_private = (void *)bdb;
 
+       (void)mbe->register_database( be );
+
        rc = mbe->register_entry_attrs( NULL, a, cb,
                base, bdb->bi_monitor.bdm_scope, filter );
 
index 2ae676a0c9644ab43d71a49380ecf982303721a7..2837113787f0deaa8e181ca42fbbe88e878a1ab9 100644 (file)
@@ -341,6 +341,93 @@ monitor_subsys_database_init_one(
        return 0;
 }
 
+int
+monitor_back_register_database(
+       BackendDB               *be )
+{
+       monitor_info_t          *mi;
+       Entry                   *e_database, **ep;
+       int                     i, rc;
+       monitor_entry_t         *mp;
+       monitor_subsys_t        *ms_backend,
+                               *ms_database,
+                               *ms_overlay;
+       struct berval           bv;
+
+       assert( be_monitor != NULL );
+
+       mi = ( monitor_info_t * )be_monitor->be_private;
+
+       ms_backend = monitor_back_get_subsys( SLAPD_MONITOR_BACKEND_NAME );
+       if ( ms_backend == NULL ) {
+               Debug( LDAP_DEBUG_ANY,
+                       "monitor_back_register_database: "
+                       "unable to get "
+                       "\"" SLAPD_MONITOR_BACKEND_NAME "\" "
+                       "subsystem\n",
+                       0, 0, 0 );
+               return -1;
+       }
+
+       ms_database = monitor_back_get_subsys( SLAPD_MONITOR_DATABASE_NAME );
+       if ( ms_backend == NULL ) {
+               Debug( LDAP_DEBUG_ANY,
+                       "monitor_back_register_database: "
+                       "unable to get "
+                       "\"" SLAPD_MONITOR_DATABASE_NAME "\" "
+                       "subsystem\n",
+                       0, 0, 0 );
+               return -1;
+       }
+
+       ms_overlay = monitor_back_get_subsys( SLAPD_MONITOR_OVERLAY_NAME );
+       if ( ms_overlay == NULL ) {
+               Debug( LDAP_DEBUG_ANY,
+                       "monitor_back_register_database: "
+                       "unable to get "
+                       "\"" SLAPD_MONITOR_OVERLAY_NAME "\" "
+                       "subsystem\n",
+                       0, 0, 0 );
+               return -1;
+       }
+
+       if ( monitor_cache_get( mi, &ms_database->mss_ndn, &e_database ) ) {
+               Debug( LDAP_DEBUG_ANY,
+                       "monitor_subsys_database_init: "
+                       "unable to get entry \"%s\"\n",
+                       ms_database->mss_ndn.bv_val, 0, 0 );
+               return( -1 );
+       }
+
+       mp = ( monitor_entry_t * )e_database->e_private;
+       for ( i = -1, ep = &mp->mp_children; *ep; i++ ) {
+               mp = ( monitor_entry_t * )(*ep)->e_private;
+
+               assert( mp != NULL );
+               ep = &mp->mp_next;
+       }
+
+       {       
+               char            buf[ BACKMONITOR_BUFSIZE ];
+
+               bv.bv_val = buf;
+               bv.bv_len = snprintf( buf, sizeof( buf ), "cn=Database %d", i );
+               if ( bv.bv_len >= sizeof( buf ) ) {
+                       return -1;
+               }
+               
+               rc = monitor_subsys_database_init_one( mi, be,
+                       ms_database, ms_backend, ms_overlay, &bv, e_database, &ep );
+               if ( rc != 0 ) {
+                       return rc;
+               }
+       }
+       
+       monitor_cache_release( mi, e_database );
+
+       return 0;
+}
+
 int
 monitor_subsys_database_init(
        BackendDB               *be,
index e2ef03be88bbaebb3fe9b66a601a029bab8770dc..780e2f5a7ce0ce7c017952c69df6c8a98b2aef72 100644 (file)
@@ -52,10 +52,10 @@ static const monitor_extra_t monitor_extra = {
        monitor_back_get_subsys_by_dn,
 
        monitor_back_register_subsys,
-       NULL,   /* monitor_back_register_backend */
-       NULL,   /* monitor_back_register_database */
-       NULL,   /* monitor_back_register_overlay_info */
-       NULL,   /* monitor_back_register_overlay */
+       monitor_back_register_backend,
+       monitor_back_register_database,
+       monitor_back_register_overlay_info,
+       monitor_back_register_overlay,
        monitor_back_register_entry,
        monitor_back_register_entry_parent,
        monitor_back_register_entry_attrs,
@@ -292,6 +292,27 @@ monitor_back_is_configured( void )
        return be_monitor != NULL;
 }
 
+int
+monitor_back_register_backend(
+       BackendInfo             *bi )
+{
+       return -1;
+}
+
+int
+monitor_back_register_overlay_info(
+       slap_overinst           *on )
+{
+       return -1;
+}
+
+int
+monitor_back_register_overlay(
+       BackendDB               *be )
+{
+       return -1;
+}
+
 int
 monitor_back_register_entry(
        Entry                   *e,
index 66306e23ae50968591a0ae3b2dd0505f605a858b..a0c8d293962fd3a01be38c5fd9345388c6cc935f 100644 (file)
@@ -137,6 +137,18 @@ monitor_entry_stub LDAP_P((
 extern int
 monitor_back_register_subsys LDAP_P((
        monitor_subsys_t        *ms ));
+extern int
+monitor_back_register_backend LDAP_P((
+       BackendInfo             *bi ));
+extern int
+monitor_back_register_database LDAP_P((
+       BackendDB               *be ));
+extern int
+monitor_back_register_overlay_info LDAP_P((
+       slap_overinst           *on ));
+extern int
+monitor_back_register_overlay LDAP_P((
+       BackendDB               *be ));
 extern monitor_subsys_t *
 monitor_back_get_subsys LDAP_P((
        const char              *name ));