From: Pierangelo Masarati Date: Tue, 22 Nov 2005 12:13:07 +0000 (+0000) Subject: set the berval length\! (ITS#4196) X-Git-Tag: OPENLDAP_REL_ENG_2_4_BP~744 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=e83f0f900b1fcb80e0ee42722948b5ec757bf4e4;p=openldap set the berval length\! (ITS#4196) --- diff --git a/servers/slapd/back-meta/config.c b/servers/slapd/back-meta/config.c index 035b5a21ec..e733fa7eb5 100644 --- a/servers/slapd/back-meta/config.c +++ b/servers/slapd/back-meta/config.c @@ -334,7 +334,15 @@ meta_back_db_config( } else if ( strcasecmp( argv[ 1 ], "disabled" ) == 0 ) { mi->mi_cache.ttl = META_DNCACHE_DISABLED; } else { - mi->mi_cache.ttl = atol( argv[ 1 ] ); + char *next; + + mi->mi_cache.ttl = strtol( argv[ 1 ], &next, 10 ); + if ( next == argv[ 1 ] || next[ 0 ] != '\0' ) { + fprintf( stderr, + "%s: line %d: unable to parse ttl \"%s\" in \"dncache-ttl \" line\n", + fname, lineno, argv[ 1 ] ); + return 1; + } } /* network timeout when connecting to ldap servers */ diff --git a/servers/slapd/back-meta/dncache.c b/servers/slapd/back-meta/dncache.c index ccaf446de6..1257862ee8 100644 --- a/servers/slapd/back-meta/dncache.c +++ b/servers/slapd/back-meta/dncache.c @@ -94,7 +94,6 @@ meta_dncache_get_target( { metadncacheentry_t tmp_entry, *entry; - time_t curr_time; int target = META_TARGET_NONE; assert( cache != NULL ); @@ -116,13 +115,7 @@ meta_dncache_get_target( target = entry->target; } else { - - /* - * Need mutex? - */ - curr_time = time( NULL ); - - if ( entry->lastupdated+cache->ttl > curr_time ) { + if ( entry->lastupdated+cache->ttl > slap_get_time() ) { target = entry->target; } } @@ -158,11 +151,7 @@ meta_dncache_update_entry( * else, cache is used with ttl */ if ( cache->ttl > 0 ) { - - /* - * Need mutex? - */ - curr_time = time( NULL ); + curr_time = slap_get_time(); } tmp_entry.dn = *ndn; @@ -178,18 +167,23 @@ meta_dncache_update_entry( } else { entry = ch_malloc( sizeof( metadncacheentry_t ) + ndn->bv_len + 1 ); if ( entry == NULL ) { - ldap_pvt_thread_mutex_unlock( &cache->mutex ); - return -1; + err = -1; + goto error_return; } + entry->dn.bv_len = ndn->bv_len; entry->dn.bv_val = (char *)&entry[ 1 ]; - AC_MEMCPY( entry->dn.bv_val, ndn->bv_val, ndn->bv_len + 1 ); + AC_MEMCPY( entry->dn.bv_val, ndn->bv_val, ndn->bv_len ); + entry->dn.bv_val[ ndn->bv_len ] = '\0'; + entry->target = target; entry->lastupdated = curr_time; err = avl_insert( &cache->tree, ( caddr_t )entry, meta_dncache_cmp, meta_dncache_dup ); } + +error_return:; ldap_pvt_thread_mutex_unlock( &cache->mutex ); return err;