From: Pierangelo Masarati Date: Sun, 2 Jan 2011 15:06:11 +0000 (+0000) Subject: make sure initialization is only tried once; improve error messages X-Git-Tag: MIGRATION_CVS2GIT~287 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=b672d8535d9b9918e419a5d6b3eee440ba7384f4;p=openldap make sure initialization is only tried once; improve error messages --- diff --git a/servers/slapd/back-bdb/monitor.c b/servers/slapd/back-bdb/monitor.c index 0ff537c323..d32815d910 100644 --- a/servers/slapd/back-bdb/monitor.c +++ b/servers/slapd/back-bdb/monitor.c @@ -245,12 +245,15 @@ bdb_monitor_initialize( void ) static int bdb_monitor_initialized = 0; - if ( backend_info( "monitor" ) == NULL ) { - return -1; - } + /* set to 0 when successfully initialized; otherwise, remember failure */ + static int bdb_monitor_initialized_failure = 1; if ( bdb_monitor_initialized++ ) { - return 0; + return bdb_monitor_initialized_failure; + } + + if ( backend_info( "monitor" ) == NULL ) { + return -1; } /* register schema here */ @@ -270,7 +273,7 @@ bdb_monitor_initialize( void ) ": unable to add " "objectIdentifier \"%s=%s\"\n", s_oid[ i ].name, s_oid[ i ].oid, 0 ); - return 1; + return 2; } } @@ -278,8 +281,10 @@ bdb_monitor_initialize( void ) code = register_at( s_at[ i ].desc, s_at[ i ].ad, 1 ); if ( code != LDAP_SUCCESS ) { Debug( LDAP_DEBUG_ANY, LDAP_XSTRING(bdb_monitor_initialize) - ": register_at failed\n", - 0, 0, 0 ); + ": register_at failed for attributeType (%s)\n", + s_at[ i ].desc, 0, 0 ); + return 3; + } else { (*s_at[ i ].ad)->ad_type->sat_flags |= SLAP_AT_HIDE; } @@ -289,14 +294,16 @@ bdb_monitor_initialize( void ) code = register_oc( s_oc[ i ].desc, s_oc[ i ].oc, 1 ); if ( code != LDAP_SUCCESS ) { Debug( LDAP_DEBUG_ANY, LDAP_XSTRING(bdb_monitor_initialize) - ": register_oc failed\n", - 0, 0, 0 ); + ": register_oc failed for objectClass (%s)\n", + s_oc[ i ].desc, 0, 0 ); + return 4; + } else { (*s_oc[ i ].oc)->soc_flags |= SLAP_OC_HIDE; } } - return 0; + return ( bdb_monitor_initialized_failure = LDAP_SUCCESS ); } /* diff --git a/servers/slapd/back-ldap/monitor.c b/servers/slapd/back-ldap/monitor.c index 678b006461..33e8ee3375 100644 --- a/servers/slapd/back-ldap/monitor.c +++ b/servers/slapd/back-ldap/monitor.c @@ -313,11 +313,14 @@ ldap_back_monitor_initialize( void ) static int ldap_back_monitor_initialized = 0; + /* set to 0 when successfully initialized; otherwise, remember failure */ + static int ldap_back_monitor_initialized_failure = 1; + /* register schema here; if compiled as dynamic object, * must be loaded __after__ back_monitor.la */ if ( ldap_back_monitor_initialized++ ) { - return 0; + return ldap_back_monitor_initialized_failure; } if ( backend_info( "monitor" ) == NULL ) { @@ -338,7 +341,7 @@ ldap_back_monitor_initialize( void ) "ldap_back_monitor_initialize: unable to add " "objectIdentifier \"%s=%s\"\n", s_oid[ i ].name, s_oid[ i ].oid, 0 ); - return 1; + return 2; } } @@ -346,8 +349,12 @@ ldap_back_monitor_initialize( void ) code = register_at( s_at[ i ].desc, s_at[ i ].ad, 1 ); if ( code != LDAP_SUCCESS ) { Debug( LDAP_DEBUG_ANY, - "ldap_back_monitor_initialize: register_at failed\n", - 0, 0, 0 ); + "ldap_back_monitor_initialize: register_at failed for attributeType (%s)\n", + s_at[ i ].desc, 0, 0 ); + return 3; + + } else { + (*s_at[ i ].ad)->ad_type->sat_flags |= SLAP_AT_HIDE; } } @@ -355,12 +362,16 @@ ldap_back_monitor_initialize( void ) code = register_oc( s_oc[ i ].desc, s_oc[ i ].oc, 1 ); if ( code != LDAP_SUCCESS ) { Debug( LDAP_DEBUG_ANY, - "ldap_back_monitor_initialize: register_oc failed\n", - 0, 0, 0 ); + "ldap_back_monitor_initialize: register_oc failed for objectClass (%s)\n", + s_oc[ i ].desc, 0, 0 ); + return 4; + + } else { + (*s_oc[ i ].oc)->soc_flags |= SLAP_OC_HIDE; } } - return 0; + return ( ldap_back_monitor_initialized_failure = LDAP_SUCCESS ); } /*