flags, li->li_mode );
lru = 0;
- pthread_mutex_lock( ¤ttime_mutex );
+ ldap_pvt_thread_mutex_lock( ¤ttime_mutex );
curtime = currenttime;
- pthread_mutex_unlock( ¤ttime_mutex );
+ ldap_pvt_thread_mutex_unlock( ¤ttime_mutex );
oldtime = curtime;
- pthread_mutex_lock( &li->li_dbcache_mutex );
+ ldap_pvt_thread_mutex_lock( &li->li_dbcache_mutex );
for ( i = 0; i < MAXDBCACHE && li->li_dbcache[i].dbc_name != NULL;
i++ ) {
/* already open - return it */
li->li_dbcache[i].dbc_refcnt++;
Debug( LDAP_DEBUG_TRACE,
"<= ldbm_cache_open (cache %d)\n", i, 0, 0 );
- pthread_mutex_unlock( &li->li_dbcache_mutex );
+ ldap_pvt_thread_mutex_unlock( &li->li_dbcache_mutex );
return( &li->li_dbcache[i] );
}
0, 0, 0 );
lru = -1;
while ( lru == -1 ) {
- pthread_cond_wait( &li->li_dbcache_cv,
+ ldap_pvt_thread_cond_wait( &li->li_dbcache_cv,
&li->li_dbcache_mutex );
for ( i = 0; i < MAXDBCACHE; i++ ) {
if ( li->li_dbcache[i].dbc_refcnt
if ( (li->li_dbcache[i].dbc_db = ldbm_open( buf, flags, li->li_mode,
li->li_dbcachesize )) == NULL ) {
+ int err = errno;
Debug( LDAP_DEBUG_TRACE,
"<= ldbm_cache_open NULL \"%s\" errno %d reason \"%s\")\n",
- buf, errno, errno > -1 && errno < sys_nerr ?
- sys_errlist[errno] : "unknown" );
- pthread_mutex_unlock( &li->li_dbcache_mutex );
+ buf, err, err > -1 && err < sys_nerr ?
+ sys_errlist[err] : "unknown" );
+ ldap_pvt_thread_mutex_unlock( &li->li_dbcache_mutex );
return( NULL );
}
- li->li_dbcache[i].dbc_name = strdup( buf );
+ li->li_dbcache[i].dbc_name = ch_strdup( buf );
li->li_dbcache[i].dbc_refcnt = 1;
li->li_dbcache[i].dbc_lastref = curtime;
if ( stat( buf, &st ) == 0 ) {
li->li_dbcache[i].dbc_blksize = DEFAULT_BLOCKSIZE;
}
li->li_dbcache[i].dbc_maxids = (li->li_dbcache[i].dbc_blksize /
- sizeof(ID)) - 2;
+ sizeof(ID)) - ID_BLOCK_IDS_OFFSET;
li->li_dbcache[i].dbc_maxindirect = (SLAPD_LDBM_MIN_MAXIDS /
li->li_dbcache[i].dbc_maxids) + 1;
li->li_dbcache[i].dbc_blksize, li->li_dbcache[i].dbc_maxids,
li->li_dbcache[i].dbc_maxindirect );
Debug( LDAP_DEBUG_TRACE, "<= ldbm_cache_open (opened %d)\n", i, 0, 0 );
- pthread_mutex_unlock( &li->li_dbcache_mutex );
+ ldap_pvt_thread_mutex_unlock( &li->li_dbcache_mutex );
return( &li->li_dbcache[i] );
}
{
struct ldbminfo *li = (struct ldbminfo *) be->be_private;
- pthread_mutex_lock( &li->li_dbcache_mutex );
+ ldap_pvt_thread_mutex_lock( &li->li_dbcache_mutex );
if ( --db->dbc_refcnt == 0 ) {
- pthread_cond_signal( &li->li_dbcache_cv );
+ ldap_pvt_thread_cond_signal( &li->li_dbcache_cv );
}
- pthread_mutex_unlock( &li->li_dbcache_mutex );
+ ldap_pvt_thread_mutex_unlock( &li->li_dbcache_mutex );
}
void
{
struct ldbminfo *li = (struct ldbminfo *) be->be_private;
- pthread_mutex_lock( &li->li_dbcache_mutex );
+ ldap_pvt_thread_mutex_lock( &li->li_dbcache_mutex );
if ( --db->dbc_refcnt == 0 ) {
- pthread_cond_signal( &li->li_dbcache_cv );
+ ldap_pvt_thread_cond_signal( &li->li_dbcache_cv );
ldbm_close( db->dbc_db );
free( db->dbc_name );
db->dbc_name = NULL;
}
- pthread_mutex_unlock( &li->li_dbcache_mutex );
+ ldap_pvt_thread_mutex_unlock( &li->li_dbcache_mutex );
}
void
struct ldbminfo *li = (struct ldbminfo *) be->be_private;
int i;
- pthread_mutex_lock( &li->li_dbcache_mutex );
+ ldap_pvt_thread_mutex_lock( &li->li_dbcache_mutex );
for ( i = 0; i < MAXDBCACHE; i++ ) {
if ( li->li_dbcache[i].dbc_name != NULL ) {
Debug( LDAP_DEBUG_TRACE, "ldbm flushing db (%s)\n",
li->li_dbcache[i].dbc_name, 0, 0 );
- pthread_mutex_lock( &li->li_dbcache[i].dbc_mutex );
ldbm_sync( li->li_dbcache[i].dbc_db );
- pthread_mutex_unlock( &li->li_dbcache[i].dbc_mutex );
}
}
- pthread_mutex_unlock( &li->li_dbcache_mutex );
+ ldap_pvt_thread_mutex_unlock( &li->li_dbcache_mutex );
}
Datum
)
{
Datum data;
-#ifdef HAVE_BERKELEY_DB2
- memset( &data, 0, sizeof( data ) );
-#endif
- pthread_mutex_lock( &db->dbc_mutex );
-#ifdef reentrant_database
- /* increment reader count */
- db->dbc_readers++
- pthread_mutex_unlock( &db->dbc_mutex );
-#endif
+ ldbm_datum_init( data );
data = ldbm_fetch( db->dbc_db, key );
-#ifdef reentrant_database
- pthread_mutex_lock( &db->dbc_mutex );
- /* decrement reader count & signal any waiting writers */
- if ( --db->dbc_readers == 0 ) {
- pthread_cond_signal( &db->dbc_cv );
- }
-#endif
- pthread_mutex_unlock( &db->dbc_mutex );
-
return( data );
}
{
int rc;
- pthread_mutex_lock( &db->dbc_mutex );
-#ifdef reentrant_database
- /* wait for reader count to drop to zero */
- while ( db->dbc_readers > 0 ) {
- pthread_cond_wait( &db->dbc_cv, &db->dbc_mutex );
- }
-#endif
-
#ifdef LDBM_DEBUG
Statslog( LDAP_DEBUG_STATS,
"=> ldbm_cache_store(): key.dptr=%s, key.dsize=%d\n",
rc = ldbm_store( db->dbc_db, key, data, flags );
- pthread_mutex_unlock( &db->dbc_mutex );
-
return( rc );
}
{
int rc;
- pthread_mutex_lock( &db->dbc_mutex );
-#ifdef reentrant_database
- /* wait for reader count to drop to zero - then write */
- while ( db->dbc_readers > 0 ) {
- pthread_cond_wait( &db->dbc_cv, &db->dbc_mutex );
- }
-#endif
-
rc = ldbm_delete( db->dbc_db, key );
- pthread_mutex_unlock( &db->dbc_mutex );
-
return( rc );
}