From: Julius Enarusai Date: Wed, 27 Mar 2002 18:20:08 +0000 (+0000) Subject: Added LDAP_LOG messages X-Git-Tag: OPENLDAP_REL_ENG_2_MP~302 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=d88bc7a8b5c5ddc376d8badeb59a8841d0ff2e22;p=openldap Added LDAP_LOG messages --- diff --git a/libraries/libldap/abandon.c b/libraries/libldap/abandon.c index 521f2d5242..70c2d97e73 100644 --- a/libraries/libldap/abandon.c +++ b/libraries/libldap/abandon.c @@ -57,7 +57,11 @@ ldap_abandon_ext( LDAPControl **cctrls ) { int rc; +#ifdef NEW_LOGGING + LDAP_LOG (( "abandon", LDAP_LEVEL_ARGS, "ldap_abandon_ext %d\n", msgid )); +#else Debug( LDAP_DEBUG_TRACE, "ldap_abandon_ext %d\n", msgid, 0, 0 ); +#endif /* check client controls */ rc = ldap_int_client_controls( ld, cctrls ); @@ -81,7 +85,11 @@ ldap_abandon_ext( int ldap_abandon( LDAP *ld, int msgid ) { +#ifdef NEW_LOGGING + LDAP_LOG (( "abandon", LDAP_LEVEL_ARGS, "ldap_abandon %d\n", msgid )); +#else Debug( LDAP_DEBUG_TRACE, "ldap_abandon %d\n", msgid, 0, 0 ); +#endif return ldap_abandon_ext( ld, msgid, NULL, NULL ) == LDAP_SUCCESS ? 0 : -1; } @@ -101,8 +109,13 @@ do_abandon( Sockbuf *sb; LDAPRequest *lr; +#ifdef NEW_LOGGING + LDAP_LOG (( "abandon", LDAP_LEVEL_ARGS, "do_abandon %d, msgid %d\n", + origid, msgid )); +#else Debug( LDAP_DEBUG_TRACE, "do_abandon origid %d, msgid %d\n", origid, msgid, 0 ); +#endif sendabandon = 1; diff --git a/libraries/libldap/add.c b/libraries/libldap/add.c index d850ba7329..1ce57eba7f 100644 --- a/libraries/libldap/add.c +++ b/libraries/libldap/add.c @@ -99,7 +99,11 @@ ldap_add_ext( BerElement *ber; int i, rc; - Debug( LDAP_DEBUG_TRACE, "ldap_add\n", 0, 0, 0 ); +#ifdef NEW_LOGGING + LDAP_LOG (( "add", LDAP_LEVEL_ENTRY, "ldap_add_ext\n" )); +#else + Debug( LDAP_DEBUG_TRACE, "ldap_add_ext\n", 0, 0, 0 ); +#endif assert( ld != NULL ); assert( LDAP_VALID( ld ) ); assert( dn != NULL ); diff --git a/libraries/libldap/bind.c b/libraries/libldap/bind.c index ca6e3a10c6..076bd17976 100644 --- a/libraries/libldap/bind.c +++ b/libraries/libldap/bind.c @@ -60,7 +60,11 @@ int ldap_bind( LDAP *ld, LDAP_CONST char *dn, LDAP_CONST char *passwd, int authmethod ) { +#ifdef NEW_LOGGING + LDAP_LOG (( "bind", LDAP_LEVEL_ENTRY, "ldap_bind\n" )); +#else Debug( LDAP_DEBUG_TRACE, "ldap_bind\n", 0, 0, 0 ); +#endif switch ( authmethod ) { case LDAP_AUTH_SIMPLE: @@ -105,7 +109,11 @@ ldap_bind_s( LDAP_CONST char *passwd, int authmethod ) { +#ifdef NEW_LOGGING + LDAP_LOG (( "bind", LDAP_LEVEL_ENTRY, "ldap_bind_s\n" )); +#else Debug( LDAP_DEBUG_TRACE, "ldap_bind_s\n", 0, 0, 0 ); +#endif switch ( authmethod ) { case LDAP_AUTH_SIMPLE: diff --git a/libraries/libldap/cache.c b/libraries/libldap/cache.c index b839bf7f75..3f56e18b80 100644 --- a/libraries/libldap/cache.c +++ b/libraries/libldap/cache.c @@ -102,7 +102,11 @@ ldap_flush_cache( LDAP *ld ) int i; LDAPMessage *m, *next; +#ifdef NEW_LOGGING + LDAP_LOG (( "cache", LDAP_LEVEL_ENTRY, "ldap_flush_cache\n" )); +#else Debug( LDAP_DEBUG_TRACE, "ldap_flush_cache\n", 0, 0, 0 ); +#endif if ( ld->ld_cache != NULL ) { /* delete all requests in the queue */ @@ -131,8 +135,14 @@ void ldap_uncache_request( LDAP *ld, int msgid ) { #ifndef LDAP_NOCACHE +#ifdef NEW_LOGGING + LDAP_LOG (( "cache", LDAP_LEVEL_ARGS, + "ldap_uncache_request %d ld_cache %lx\n", + msgid, (long) ld->ld_cache )); +#else Debug( LDAP_DEBUG_TRACE, "ldap_uncache_request %d ld_cache %lx\n", msgid, (long) ld->ld_cache, 0 ); +#endif uncache_entry_or_req( ld, NULL, msgid ); #endif @@ -143,8 +153,14 @@ void ldap_uncache_entry( LDAP *ld, LDAP_CONST char *dn ) { #ifndef LDAP_NOCACHE +#ifdef NEW_LOGGING + LDAP_LOG (( "cache", LDAP_LEVEL_ARGS, + "ldap_uncache_entry %s ld_cache %lx\n", + dn, (long) ld->ld_cache )); +#else Debug( LDAP_DEBUG_TRACE, "ldap_uncache_entry %s ld_cache %lx\n", dn, (long) ld->ld_cache, 0 ); +#endif uncache_entry_or_req( ld, dn, 0 ); #endif @@ -161,9 +177,15 @@ uncache_entry_or_req( LDAP *ld, int i; LDAPMessage *m, *prev, *next; +#ifdef NEW_LOGGING + LDAP_LOG (( "cache", LDAP_LEVEL_ARGS, + "uncache_entry_or_req dn %s msgid %ld ld_cache %lx\n", + dn, (long) msgid, (long) ld->ld_cache )); +#else Debug( LDAP_DEBUG_TRACE, "ldap_uncache_entry_or_req dn %s msgid %ld ld_cache %lx\n", dn, (long) msgid, (long) ld->ld_cache ); +#endif if ( ld->ld_cache == NULL ) { return; @@ -218,7 +240,11 @@ ldap_add_request_to_cache( LDAP *ld, ber_tag_t msgtype, BerElement *request ) LDAPMessage *new; ber_len_t len; +#ifdef NEW_LOGGING + LDAP_LOG (( "cache", LDAP_LEVEL_ENTRY, "ldap_add_request_to_cache\n" )); +#else Debug( LDAP_DEBUG_TRACE, "ldap_add_request_to_cache\n", 0, 0, 0 ); +#endif ld->ld_errno = LDAP_SUCCESS; if ( ld->ld_cache == NULL || @@ -262,12 +288,23 @@ ldap_add_result_to_cache( LDAP *ld, LDAPMessage *result ) LDAPMessage *m, **mp, *req, *new, *prev; int err, keep; +#ifdef NEW_LOGGING + LDAP_LOG (( "cache", LDAP_LEVEL_ARGS, + "ldap_add_result_to_cache: id %ld, type %ld\n", + (long) result->lm_msgid, (long) result->lm_msgtype )); +#else Debug( LDAP_DEBUG_TRACE, "ldap_add_result_to_cache: id %ld, type %ld\n", (long) result->lm_msgid, (long) result->lm_msgtype, 0 ); +#endif if ( ld->ld_cache == NULL || ( ld->ld_cache->lc_enabled == 0 )) { +#ifdef NEW_LOGGING + LDAP_LOG (( "cache", LDAP_LEVEL_DETAIL1, + "ldap_add_result_to_cache: cache disabled\n" )); +#else Debug( LDAP_DEBUG_TRACE, "artc: cache disabled\n", 0, 0, 0 ); +#endif return; } @@ -278,8 +315,14 @@ ldap_add_result_to_cache( LDAP *ld, LDAPMessage *result ) /* * only cache search and compare operations */ +#ifdef NEW_LOGGING + LDAP_LOG (( "cache", LDAP_LEVEL_DETAIL1, + "ldap_add_result_to_cache: " + "only caching search & compare operations\n" )); +#else Debug( LDAP_DEBUG_TRACE, "artc: only caching search & compare operations\n", 0, 0, 0 ); +#endif return; } @@ -303,9 +346,15 @@ ldap_add_result_to_cache( LDAP *ld, LDAPMessage *result ) if (( new = msg_dup( result )) != NULL ) { new->lm_chain = NULL; m->lm_chain = new; +#ifdef NEW_LOGGING + LDAP_LOG (( "cache", LDAP_LEVEL_RESULTS, + "ldap_add_result_to_cache: " + "result added to cache request chain\n" )); +#else Debug( LDAP_DEBUG_TRACE, "artc: result added to cache request chain\n", 0, 0, 0 ); +#endif } if ( result->lm_msgtype == LDAP_RES_SEARCH_RESULT || result->lm_msgtype == LDAP_RES_COMPARE ) { @@ -339,9 +388,15 @@ ldap_add_result_to_cache( LDAP *ld, LDAPMessage *result ) } if ( !keep ) { +#ifdef NEW_LOGGING + LDAP_LOG (( "cache", LDAP_LEVEL_RESULTS, + "ldap_add_result_to_cache: " + "not caching result with error\n" )); +#else Debug( LDAP_DEBUG_TRACE, "artc: not caching result with error %d\n", err, 0, 0 ); +#endif ldap_msgfree( req ); } else { mp = &ld->ld_cache->lc_buckets[ @@ -351,14 +406,26 @@ ldap_add_result_to_cache( LDAP *ld, LDAPMessage *result ) req->lm_time = (long) time( NULL ); ld->ld_cache->lc_memused += msg_size( req ); check_cache_memused( ld->ld_cache ); +#ifdef NEW_LOGGING + LDAP_LOG (( "cache", LDAP_LEVEL_RESULTS, + "ldap_add_result_to_cache: " + "cached result with error\n" )); +#else Debug( LDAP_DEBUG_TRACE, "artc: cached result with error %d\n", err, 0, 0 ); +#endif } } } else { +#ifdef NEW_LOGGING + LDAP_LOG (( "cache", LDAP_LEVEL_RESULTS, + "ldap_add_result_to_cache: " + "msgid not in request list\n" )); +#else Debug( LDAP_DEBUG_TRACE, "artc: msgid not in request list\n", 0, 0, 0 ); +#endif } #endif } @@ -380,7 +447,11 @@ ldap_check_cache( LDAP *ld, ber_tag_t msgtype, BerElement *request ) int first, hash; time_t c_time; +#ifdef NEW_LOGGING + LDAP_LOG (( "cache", LDAP_LEVEL_ENTRY, "ldap_check_cache\n" )); +#else Debug( LDAP_DEBUG_TRACE, "ldap_check_cache\n", 0, 0, 0 ); +#endif if ( ld->ld_cache == NULL || ( ld->ld_cache->lc_enabled == 0 )) { @@ -398,8 +469,14 @@ ldap_check_cache( LDAP *ld, ber_tag_t msgtype, BerElement *request ) prev = NULL; hash = cache_hash( &reqber ); for ( m = ld->ld_cache->lc_buckets[ hash ]; m != NULL; m = next ) { +#ifdef NEW_LOGGING + LDAP_LOG (( "cache", LDAP_LEVEL_DETAIL1, + "ldap_check_cache: examining id %ld, type %ld\n", + (long) m->lm_msgid, (long) m->lm_msgtype )); +#else Debug( LDAP_DEBUG_TRACE,"cc: examining id %ld,type %ld\n", (long) m->lm_msgid, (long) m->lm_msgtype, 0 ); +#endif if ( difftime(c_time, m->lm_time) > ld->ld_cache->lc_timeout ) { /* delete expired message */ next = m->lm_next; @@ -408,8 +485,14 @@ ldap_check_cache( LDAP *ld, ber_tag_t msgtype, BerElement *request ) } else { prev->lm_next = next; } +#ifdef NEW_LOGGING + LDAP_LOG (( "cache", LDAP_LEVEL_DETAIL1, + "ldap_check_cache: expired id %ld\n", + (long) m->lm_msgid )); +#else Debug( LDAP_DEBUG_TRACE, "cc: expired id %d\n", m->lm_msgid, 0, 0 ); +#endif ld->ld_cache->lc_memused -= msg_size( m ); ldap_msgfree( m ); } else { @@ -445,11 +528,22 @@ ldap_check_cache( LDAP *ld, ber_tag_t msgtype, BerElement *request ) prev->lm_chain = new; } prev = new; +#ifdef NEW_LOGGING + LDAP_LOG (( "cache", LDAP_LEVEL_DETAIL1, + "ldap_check_cache: added type %ld\n", + (long) m->lm_msgtype )); +#else Debug( LDAP_DEBUG_TRACE, "cc: added type %ld\n", (long) new->lm_msgtype, 0, 0 ); +#endif } +#ifdef NEW_LOGGING + LDAP_LOG (( "cache", LDAP_LEVEL_RESULTS, + "ldap_check_cache: result returned from cache\n" )); +#else Debug( LDAP_DEBUG_TRACE, "cc: result returned from cache\n", 0, 0, 0 ); +#endif return( 0 ); #else return( -1 ); @@ -475,8 +569,14 @@ cache_hash( BerElement *ber ) len = bercpy.ber_end - bercpy.ber_ptr; } +#ifdef NEW_LOGGING + LDAP_LOG (( "cache", LDAP_LEVEL_RESULTS, + "cache_hash: len is %ld, returning %ld\n", + len, len % LDAP_CACHE_BUCKETS )); +#else Debug( LDAP_DEBUG_TRACE, "cache_hash: len is %ld, returning %ld\n", len, len % LDAP_CACHE_BUCKETS, 0 ); +#endif return( (int) ( len % LDAP_CACHE_BUCKETS )); } @@ -626,8 +726,14 @@ check_cache_memused( LDAPCache *lc ) time_t c_time; LDAPMessage *m, *prev, *next; +#ifdef NEW_LOGGING + LDAP_LOG (( "cache", LDAP_LEVEL_DETAIL1, + "check_cache_memused: %ld bytes in use (%ld max)\n", + lc->lc_memused, lc->lc_maxmem )); +#else Debug( LDAP_DEBUG_TRACE, "check_cache_memused: %ld bytes in use (%ld max)\n", lc->lc_memused, lc->lc_maxmem, 0 ); +#endif if ( (unsigned) lc->lc_maxmem <= sizeof( LDAPCache ) || lc->lc_memused <= lc->lc_maxmem * SIZE_FACTOR ) { @@ -649,9 +755,15 @@ check_cache_memused( LDAPCache *lc ) prev->lm_next = next; } lc->lc_memused -= msg_size( m ); +#ifdef NEW_LOGGING + LDAP_LOG (( "cache", LDAP_LEVEL_DETAIL1, + "check_cache_memused: removed %ld\n", + m->lm_msgid )); +#else Debug( LDAP_DEBUG_TRACE, "ccm: removed %d\n", m->lm_msgid, 0, 0 ); +#endif ldap_msgfree( m ); } else { prev = m; @@ -661,8 +773,14 @@ check_cache_memused( LDAPCache *lc ) remove_threshold *= THRESHOLD_FACTOR; } +#ifdef NEW_LOGGING + LDAP_LOG (( "cache", LDAP_LEVEL_DETAIL1, + "check_cache_memused: reduced usage to %ld bytes\n", + lc->lm_memused )); +#else Debug( LDAP_DEBUG_TRACE, "ccm: reduced usage to %ld bytes\n", lc->lc_memused, 0, 0 ); +#endif } #endif /* !NO_CACHE */