mirror of
https://git.openldap.org/openldap/openldap.git
synced 2025-12-20 22:59:34 -05:00
Merged in per cache entry reader/writer locks from OPENLDAP_DEVEL_THREAD
This commit is contained in:
parent
4caf68cf43
commit
4a5d740e2e
24 changed files with 606 additions and 241 deletions
|
|
@ -205,8 +205,8 @@ LDBMLIB?=
|
|||
# -DTHREAD_SUNOS4_LWP
|
||||
# -DTHREAD_SUNOS5_LWP
|
||||
# and select the appropriate library.
|
||||
#THREADS?=-DNO_THREADS
|
||||
#THREADSLIB?=
|
||||
THREADS?=-DNO_THREADS
|
||||
THREADSLIB?=
|
||||
|
||||
# Locations of auxilary programs
|
||||
# (excepts to below are generally defined in Make-platform)
|
||||
|
|
|
|||
|
|
@ -109,4 +109,4 @@ int pthread_rdwr_rwchk_np(pthread_rdwr_t *rdwrp)
|
|||
return(pthread_rdwr_rchk_np(rdwrp) || pthread_rdwr_wchk_np(rdwrp));
|
||||
}
|
||||
|
||||
#endif LDAP_DEBUG
|
||||
#endif /* LDAP_DEBUG */
|
||||
|
|
|
|||
|
|
@ -25,7 +25,6 @@ static int regex_matches();
|
|||
static string_expand(char *newbuf, int bufsiz, char *pattern,
|
||||
char *match, regmatch_t *matches);
|
||||
|
||||
extern Entry * be_dn2entry(Backend *be, char *bdn, char **matched);
|
||||
|
||||
/*
|
||||
* access_allowed - check whether dn is allowed the requested access
|
||||
|
|
@ -549,7 +548,7 @@ regex_matches(
|
|||
char error[512];
|
||||
regerror(rc, &re, error, sizeof(error));
|
||||
|
||||
Debug( LDAP_DEBUG_ANY,
|
||||
Debug( LDAP_DEBUG_TRACE,
|
||||
"compile( \"%s\", \"%s\") failed %s\n",
|
||||
pat, str, error );
|
||||
return( 0 );
|
||||
|
|
|
|||
|
|
@ -53,6 +53,8 @@ do_add( conn, op )
|
|||
*/
|
||||
|
||||
e = (Entry *) ch_calloc( 1, sizeof(Entry) );
|
||||
/* initialize reader/writer lock */
|
||||
entry_rdwr_init(e);
|
||||
|
||||
/* get the name */
|
||||
if ( ber_scanf( ber, "{a", &dn ) == LBER_ERROR ) {
|
||||
|
|
|
|||
|
|
@ -6,11 +6,11 @@
|
|||
#include <sys/socket.h>
|
||||
#include "slap.h"
|
||||
#include "back-ldbm.h"
|
||||
#include "proto-back-ldbm.h"
|
||||
|
||||
extern int global_schemacheck;
|
||||
extern char *dn_parent();
|
||||
extern char *dn_normalize();
|
||||
extern Entry *dn2entry();
|
||||
|
||||
int
|
||||
ldbm_back_add(
|
||||
|
|
@ -21,27 +21,30 @@ ldbm_back_add(
|
|||
)
|
||||
{
|
||||
struct ldbminfo *li = (struct ldbminfo *) be->be_private;
|
||||
char *matched;
|
||||
char *dn = NULL, *pdn = NULL;
|
||||
Entry *p;
|
||||
Entry *p = NULL;
|
||||
int rc;
|
||||
|
||||
dn = dn_normalize( strdup( e->e_dn ) );
|
||||
matched = NULL;
|
||||
if ( (p = dn2entry( be, dn, &matched )) != NULL ) {
|
||||
cache_return_entry( &li->li_cache, p );
|
||||
|
||||
Debug(LDAP_DEBUG_ARGS, "==> ldbm_back_add: %s\n", dn, 0, 0);
|
||||
|
||||
if ( ( dn2id( be, dn ) ) != NOID ) {
|
||||
entry_free( e );
|
||||
free( dn );
|
||||
send_ldap_result( conn, op, LDAP_ALREADY_EXISTS, "", "" );
|
||||
return( -1 );
|
||||
}
|
||||
if ( matched != NULL ) {
|
||||
free( matched );
|
||||
}
|
||||
|
||||
/* XXX race condition here til we cache_add_entry_lock below XXX */
|
||||
|
||||
if ( global_schemacheck && oc_schema_check( e ) != 0 ) {
|
||||
Debug( LDAP_DEBUG_TRACE, "entry failed schema check\n", 0, 0,
|
||||
0 );
|
||||
Debug( LDAP_DEBUG_TRACE, "entry failed schema check\n",
|
||||
0, 0, 0 );
|
||||
|
||||
/* XXX this should be ok, no other thread should have access
|
||||
* because e hasn't been added to the cache yet
|
||||
*/
|
||||
entry_free( e );
|
||||
free( dn );
|
||||
send_ldap_result( conn, op, LDAP_OBJECT_CLASS_VIOLATION, "",
|
||||
|
|
@ -61,6 +64,10 @@ ldbm_back_add(
|
|||
Debug( LDAP_DEBUG_ANY, "cache_add_entry_lock failed\n", 0, 0,
|
||||
0 );
|
||||
next_id_return( be, e->e_id );
|
||||
|
||||
/* XXX this should be ok, no other thread should have access
|
||||
* because e hasn't been added to the cache yet
|
||||
*/
|
||||
entry_free( e );
|
||||
free( dn );
|
||||
send_ldap_result( conn, op, LDAP_ALREADY_EXISTS, "", "" );
|
||||
|
|
@ -74,17 +81,22 @@ ldbm_back_add(
|
|||
*/
|
||||
|
||||
if ( (pdn = dn_parent( be, dn )) != NULL ) {
|
||||
char *matched;
|
||||
/* no parent */
|
||||
matched = NULL;
|
||||
if ( (p = dn2entry( be, pdn, &matched )) == NULL ) {
|
||||
|
||||
/* get entry with reader lock */
|
||||
if ( (p = dn2entry_r( be, pdn, &matched )) == NULL ) {
|
||||
Debug( LDAP_DEBUG_TRACE, "parent does not exist\n", 0,
|
||||
0, 0 );
|
||||
send_ldap_result( conn, op, LDAP_NO_SUCH_OBJECT,
|
||||
matched, "" );
|
||||
if ( matched != NULL ) {
|
||||
free( matched );
|
||||
}
|
||||
Debug( LDAP_DEBUG_TRACE, "parent does not exist\n", 0,
|
||||
0, 0 );
|
||||
goto error_return;
|
||||
|
||||
rc = -1;
|
||||
goto return_results;
|
||||
}
|
||||
if ( matched != NULL ) {
|
||||
free( matched );
|
||||
|
|
@ -96,7 +108,9 @@ ldbm_back_add(
|
|||
0, 0 );
|
||||
send_ldap_result( conn, op, LDAP_INSUFFICIENT_ACCESS,
|
||||
"", "" );
|
||||
goto error_return;
|
||||
|
||||
rc = -1;
|
||||
goto return_results;
|
||||
}
|
||||
} else {
|
||||
if ( ! be_isroot( be, op->o_dn ) ) {
|
||||
|
|
@ -104,9 +118,10 @@ ldbm_back_add(
|
|||
0, 0 );
|
||||
send_ldap_result( conn, op, LDAP_INSUFFICIENT_ACCESS,
|
||||
"", "" );
|
||||
goto error_return;
|
||||
|
||||
rc = -1;
|
||||
goto return_results;
|
||||
}
|
||||
p = NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
@ -116,9 +131,10 @@ ldbm_back_add(
|
|||
if ( id2children_add( be, p, e ) != 0 ) {
|
||||
Debug( LDAP_DEBUG_TRACE, "id2children_add failed\n", 0,
|
||||
0, 0 );
|
||||
send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR, "",
|
||||
"" );
|
||||
goto error_return;
|
||||
send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR, "", "" );
|
||||
|
||||
rc = -1;
|
||||
goto return_results;
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
@ -131,7 +147,9 @@ ldbm_back_add(
|
|||
Debug( LDAP_DEBUG_TRACE, "index_add_entry failed\n", 0,
|
||||
0, 0 );
|
||||
send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR, "", "" );
|
||||
goto error_return;
|
||||
|
||||
rc = -1;
|
||||
goto return_results;
|
||||
}
|
||||
|
||||
/* dn2id index */
|
||||
|
|
@ -139,35 +157,44 @@ ldbm_back_add(
|
|||
Debug( LDAP_DEBUG_TRACE, "dn2id_add failed\n", 0,
|
||||
0, 0 );
|
||||
send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR, "", "" );
|
||||
goto error_return;
|
||||
|
||||
rc = -1;
|
||||
goto return_results;
|
||||
}
|
||||
|
||||
/* acquire writer lock */
|
||||
entry_rdwr_lock(e, 1);
|
||||
|
||||
/* id2entry index */
|
||||
if ( id2entry_add( be, e ) != 0 ) {
|
||||
Debug( LDAP_DEBUG_TRACE, "id2entry_add failed\n", 0,
|
||||
0, 0 );
|
||||
(void) dn2id_delete( be, dn );
|
||||
send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR, "", "" );
|
||||
goto error_return;
|
||||
|
||||
rc = -1;
|
||||
goto return_results;
|
||||
}
|
||||
|
||||
send_ldap_result( conn, op, LDAP_SUCCESS, "", "" );
|
||||
rc = 0;
|
||||
|
||||
return_results:;
|
||||
|
||||
if ( dn != NULL )
|
||||
free( dn );
|
||||
if ( pdn != NULL )
|
||||
free( pdn );
|
||||
|
||||
cache_set_state( &li->li_cache, e, 0 );
|
||||
cache_return_entry( &li->li_cache, e );
|
||||
return( 0 );
|
||||
|
||||
error_return:;
|
||||
if ( dn != NULL )
|
||||
free( dn );
|
||||
if ( pdn != NULL )
|
||||
free( pdn );
|
||||
next_id_return( be, e->e_id );
|
||||
cache_delete_entry( &li->li_cache, e );
|
||||
cache_return_entry( &li->li_cache, e );
|
||||
/* free entry and writer lock */
|
||||
cache_return_entry_w( &li->li_cache, e );
|
||||
|
||||
return( -1 );
|
||||
/* free entry and reader lock */
|
||||
if (p != NULL) {
|
||||
cache_return_entry_r( &li->li_cache, p );
|
||||
}
|
||||
|
||||
return( rc );
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@
|
|||
#include <sys/socket.h>
|
||||
#include "slap.h"
|
||||
#include "back-ldbm.h"
|
||||
#include "proto-back-ldbm.h"
|
||||
#ifdef KERBEROS
|
||||
#ifdef KERBEROS_V
|
||||
#include <kerberosIV/krb.h>
|
||||
|
|
@ -32,7 +33,6 @@ extern char *crypt (char *key, char *salt);
|
|||
|
||||
#include <lutil.h>
|
||||
|
||||
extern Entry *dn2entry();
|
||||
extern Attribute *attr_find();
|
||||
|
||||
#ifdef KERBEROS
|
||||
|
|
@ -140,7 +140,10 @@ ldbm_back_bind(
|
|||
AUTH_DAT ad;
|
||||
#endif
|
||||
|
||||
if ( (e = dn2entry( be, dn, &matched )) == NULL ) {
|
||||
Debug(LDAP_DEBUG_ARGS, "==> ldbm_back_bind: dn: %s\n", dn, 0, 0);
|
||||
|
||||
/* get entry with reader lock */
|
||||
if ( (e = dn2entry_r( be, dn, &matched )) == NULL ) {
|
||||
/* allow noauth binds */
|
||||
if ( method == LDAP_AUTH_SIMPLE && cred->bv_len == 0 ) {
|
||||
/*
|
||||
|
|
@ -153,8 +156,7 @@ ldbm_back_bind(
|
|||
/* front end will send result */
|
||||
rc = 0;
|
||||
} else {
|
||||
send_ldap_result( conn, op, LDAP_NO_SUCH_OBJECT,
|
||||
matched, NULL );
|
||||
send_ldap_result( conn, op, LDAP_NO_SUCH_OBJECT, matched, NULL );
|
||||
rc = 1;
|
||||
}
|
||||
if ( matched != NULL ) {
|
||||
|
|
@ -163,25 +165,32 @@ ldbm_back_bind(
|
|||
return( rc );
|
||||
}
|
||||
|
||||
/* check for deleted */
|
||||
|
||||
switch ( method ) {
|
||||
case LDAP_AUTH_SIMPLE:
|
||||
if ( cred->bv_len == 0 ) {
|
||||
send_ldap_result( conn, op, LDAP_SUCCESS, NULL, NULL );
|
||||
return( 1 );
|
||||
|
||||
/* stop front end from sending result */
|
||||
rc = 1;
|
||||
goto return_results;
|
||||
} else if ( be_isroot_pw( be, dn, cred ) ) {
|
||||
/* front end will send result */
|
||||
return( 0 );
|
||||
rc = 0;
|
||||
goto return_results;
|
||||
}
|
||||
|
||||
if ( (a = attr_find( e->e_attrs, "userpassword" )) == NULL ) {
|
||||
if ( be_isroot_pw( be, dn, cred ) ) {
|
||||
/* front end will send result */
|
||||
return( 0 );
|
||||
rc = 0;
|
||||
goto return_results;
|
||||
}
|
||||
send_ldap_result( conn, op, LDAP_INAPPROPRIATE_AUTH,
|
||||
NULL, NULL );
|
||||
cache_return_entry( &li->li_cache, e );
|
||||
return( 1 );
|
||||
rc = 1;
|
||||
goto return_results;
|
||||
}
|
||||
|
||||
#ifdef LDAP_CRYPT
|
||||
|
|
@ -189,16 +198,18 @@ ldbm_back_bind(
|
|||
#else
|
||||
if ( value_find( a->a_vals, cred, a->a_syntax, 0 ) != 0 )
|
||||
#endif
|
||||
{
|
||||
{
|
||||
if ( be_isroot_pw( be, dn, cred ) ) {
|
||||
/* front end will send result */
|
||||
return( 0 );
|
||||
rc = 0;
|
||||
goto return_results;
|
||||
}
|
||||
send_ldap_result( conn, op, LDAP_INVALID_CREDENTIALS,
|
||||
NULL, NULL );
|
||||
cache_return_entry( &li->li_cache, e );
|
||||
return( 1 );
|
||||
rc = 1;
|
||||
goto return_results;
|
||||
}
|
||||
rc = 0;
|
||||
break;
|
||||
|
||||
#ifdef KERBEROS
|
||||
|
|
@ -206,8 +217,8 @@ ldbm_back_bind(
|
|||
if ( krbv4_ldap_auth( be, cred, &ad ) != LDAP_SUCCESS ) {
|
||||
send_ldap_result( conn, op, LDAP_INVALID_CREDENTIALS,
|
||||
NULL, NULL );
|
||||
cache_return_entry( &li->li_cache, e );
|
||||
return( 1 );
|
||||
rc = 0;
|
||||
goto return_results;
|
||||
}
|
||||
sprintf( krbname, "%s%s%s@%s", ad.pname, *ad.pinst ? "."
|
||||
: "", ad.pinst, ad.prealm );
|
||||
|
|
@ -216,43 +227,47 @@ ldbm_back_bind(
|
|||
* no krbName values present: check against DN
|
||||
*/
|
||||
if ( strcasecmp( dn, krbname ) == 0 ) {
|
||||
rc = 0; /* XXX wild ass guess */
|
||||
break;
|
||||
}
|
||||
send_ldap_result( conn, op, LDAP_INAPPROPRIATE_AUTH,
|
||||
NULL, NULL );
|
||||
cache_return_entry( &li->li_cache, e );
|
||||
return( 1 );
|
||||
rc = 1;
|
||||
goto return_results;
|
||||
} else { /* look for krbName match */
|
||||
struct berval krbval;
|
||||
|
||||
krbval.bv_val = krbname;
|
||||
krbval.bv_len = strlen( krbname );
|
||||
|
||||
if ( value_find( a->a_vals, &krbval, a->a_syntax, 3 )
|
||||
!= 0 ) {
|
||||
if ( value_find( a->a_vals, &krbval, a->a_syntax, 3 ) != 0 ) {
|
||||
send_ldap_result( conn, op,
|
||||
LDAP_INVALID_CREDENTIALS, NULL, NULL );
|
||||
cache_return_entry( &li->li_cache, e );
|
||||
return( 1 );
|
||||
rc = 1;
|
||||
goto return_results;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case LDAP_AUTH_KRBV42:
|
||||
send_ldap_result( conn, op, LDAP_SUCCESS, NULL, NULL );
|
||||
cache_return_entry( &li->li_cache, e );
|
||||
return( 1 );
|
||||
/* stop front end from sending result */
|
||||
rc = 1;
|
||||
goto return_results;
|
||||
#endif
|
||||
|
||||
default:
|
||||
send_ldap_result( conn, op, LDAP_STRONG_AUTH_NOT_SUPPORTED,
|
||||
NULL, "auth method not supported" );
|
||||
cache_return_entry( &li->li_cache, e );
|
||||
return( 1 );
|
||||
rc = 1;
|
||||
goto return_results;
|
||||
}
|
||||
|
||||
cache_return_entry( &li->li_cache, e );
|
||||
return_results:;
|
||||
/* free entry and reader lock */
|
||||
cache_return_entry_r( &li->li_cache, e );
|
||||
|
||||
/* success: front end will send result */
|
||||
return( 0 );
|
||||
/* front end with send result on success (rc==0) */
|
||||
return( rc );
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ cache_set_state( struct cache *cache, Entry *e, int state )
|
|||
pthread_mutex_unlock( &cache->c_mutex );
|
||||
}
|
||||
|
||||
void
|
||||
static void
|
||||
cache_return_entry( struct cache *cache, Entry *e )
|
||||
{
|
||||
/* set cache mutex */
|
||||
|
|
@ -66,6 +66,28 @@ cache_return_entry( struct cache *cache, Entry *e )
|
|||
pthread_mutex_unlock( &cache->c_mutex );
|
||||
}
|
||||
|
||||
static void
|
||||
cache_return_entry_rw( struct cache *cache, Entry *e, int rw )
|
||||
{
|
||||
Debug( LDAP_DEBUG_TRACE, "====> cache_return_entry_%s\n",
|
||||
rw ? "w" : "r", 0, 0);
|
||||
entry_rdwr_unlock(e, rw);;
|
||||
cache_return_entry(cache, e);
|
||||
}
|
||||
|
||||
void
|
||||
cache_return_entry_r( struct cache *cache, Entry *e )
|
||||
{
|
||||
cache_return_entry_rw(cache, e, 0);
|
||||
}
|
||||
|
||||
void
|
||||
cache_return_entry_w( struct cache *cache, Entry *e )
|
||||
{
|
||||
cache_return_entry_rw(cache, e, 1);
|
||||
}
|
||||
|
||||
|
||||
#define LRU_DELETE( cache, e ) { \
|
||||
if ( e->e_lruprev != NULL ) { \
|
||||
e->e_lruprev->e_lrunext = e->e_lrunext; \
|
||||
|
|
@ -113,8 +135,8 @@ cache_add_entry_lock(
|
|||
if ( avl_insert( &cache->c_dntree, e, cache_entrydn_cmp, avl_dup_error )
|
||||
!= 0 ) {
|
||||
Debug( LDAP_DEBUG_TRACE,
|
||||
"entry %20s id %d already in dn cache\n", e->e_dn,
|
||||
e->e_id, 0 );
|
||||
"====> cache_add_entry lock: entry %20s id %d already in dn cache\n",
|
||||
e->e_dn, e->e_id, 0 );
|
||||
|
||||
/* free cache mutex */
|
||||
pthread_mutex_unlock( &cache->c_mutex );
|
||||
|
|
@ -124,13 +146,14 @@ cache_add_entry_lock(
|
|||
/* id tree */
|
||||
if ( avl_insert( &cache->c_idtree, e, cache_entryid_cmp, avl_dup_error )
|
||||
!= 0 ) {
|
||||
Debug( LDAP_DEBUG_ANY, "entry %20s id %d already in id cache\n",
|
||||
Debug( LDAP_DEBUG_ANY,
|
||||
"====> entry %20s id %d already in id cache\n",
|
||||
e->e_dn, e->e_id, 0 );
|
||||
|
||||
/* delete from dn tree inserted above */
|
||||
if ( avl_delete( &cache->c_dntree, e, cache_entrydn_cmp )
|
||||
== NULL ) {
|
||||
Debug( LDAP_DEBUG_ANY, "can't delete from dn cache\n",
|
||||
Debug( LDAP_DEBUG_ANY, "====> can't delete from dn cache\n",
|
||||
0, 0, 0 );
|
||||
}
|
||||
|
||||
|
|
@ -168,6 +191,9 @@ cache_add_entry_lock(
|
|||
== 0 && cache->c_cursize > cache->c_maxsize ) {
|
||||
e = cache->c_lrutail;
|
||||
|
||||
/* XXX check for writer lock - should also check no readers pending */
|
||||
assert(pthread_rdwr_wchk_np(&e->e_rdwr));
|
||||
|
||||
/* delete from cache and lru q */
|
||||
rc = cache_delete_entry_internal( cache, e );
|
||||
|
||||
|
|
@ -181,23 +207,31 @@ cache_add_entry_lock(
|
|||
}
|
||||
|
||||
/*
|
||||
* cache_find_entry_dn - find an entry in the cache, given dn
|
||||
* cache_find_entry_dn2id - find an entry in the cache, given dn
|
||||
*/
|
||||
|
||||
Entry *
|
||||
cache_find_entry_dn(
|
||||
ID
|
||||
cache_find_entry_dn2id(
|
||||
Backend *be,
|
||||
struct cache *cache,
|
||||
char *dn
|
||||
)
|
||||
{
|
||||
struct ldbminfo *li = (struct ldbminfo *) be->be_private;
|
||||
Entry e, *ep;
|
||||
ID id;
|
||||
|
||||
/* set cache mutex */
|
||||
pthread_mutex_lock( &cache->c_mutex );
|
||||
|
||||
e.e_dn = dn;
|
||||
|
||||
if ( (ep = (Entry *) avl_find( cache->c_dntree, &e, cache_entrydn_cmp ))
|
||||
!= NULL ) {
|
||||
|
||||
Debug(LDAP_DEBUG_TRACE, "====> cache_find_entry_dn2id: found dn: %s\n",
|
||||
dn, 0, 0);
|
||||
|
||||
/*
|
||||
* entry is deleted or not fully created yet
|
||||
*/
|
||||
|
|
@ -206,19 +240,52 @@ cache_find_entry_dn(
|
|||
{
|
||||
/* free cache mutex */
|
||||
pthread_mutex_unlock( &cache->c_mutex );
|
||||
return( NULL );
|
||||
return( NOID );
|
||||
}
|
||||
|
||||
/* XXX is this safe without writer lock? */
|
||||
ep->e_refcnt++;
|
||||
|
||||
/* lru */
|
||||
LRU_DELETE( cache, ep );
|
||||
LRU_ADD( cache, ep );
|
||||
|
||||
/* acquire reader lock */
|
||||
entry_rdwr_lock(ep, 0);
|
||||
|
||||
/* re-check */
|
||||
if ( ep->e_state == ENTRY_STATE_DELETED ||
|
||||
ep->e_state == ENTRY_STATE_CREATING )
|
||||
{
|
||||
/* XXX check that is is required */
|
||||
ep->e_refcnt--;
|
||||
|
||||
/* free reader lock */
|
||||
entry_rdwr_unlock(ep, 0);
|
||||
/* free cache mutex */
|
||||
pthread_mutex_unlock( &cache->c_mutex );
|
||||
|
||||
return( NOID );
|
||||
}
|
||||
|
||||
/* save id */
|
||||
id = ep->e_id;
|
||||
|
||||
/* free reader lock */
|
||||
entry_rdwr_unlock(ep, 0);
|
||||
|
||||
/* free cache mutex */
|
||||
pthread_mutex_unlock( &cache->c_mutex );
|
||||
|
||||
cache_return_entry( &li->li_cache, ep );
|
||||
|
||||
return( id );
|
||||
}
|
||||
|
||||
/* free cache mutex */
|
||||
pthread_mutex_unlock( &cache->c_mutex );
|
||||
|
||||
return( ep );
|
||||
return( NOID );
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
@ -228,7 +295,8 @@ cache_find_entry_dn(
|
|||
Entry *
|
||||
cache_find_entry_id(
|
||||
struct cache *cache,
|
||||
ID id
|
||||
ID id,
|
||||
int rw
|
||||
)
|
||||
{
|
||||
Entry e;
|
||||
|
|
@ -238,8 +306,14 @@ cache_find_entry_id(
|
|||
pthread_mutex_lock( &cache->c_mutex );
|
||||
|
||||
e.e_id = id;
|
||||
|
||||
if ( (ep = (Entry *) avl_find( cache->c_idtree, &e, cache_entryid_cmp ))
|
||||
!= NULL ) {
|
||||
|
||||
Debug(LDAP_DEBUG_TRACE,
|
||||
"====> cache_find_entry_dn2id: found id: %ld rw: %d\n",
|
||||
id, rw, 0);
|
||||
|
||||
/*
|
||||
* entry is deleted or not fully created yet
|
||||
*/
|
||||
|
|
@ -250,17 +324,46 @@ cache_find_entry_id(
|
|||
pthread_mutex_unlock( &cache->c_mutex );
|
||||
return( NULL );
|
||||
}
|
||||
/* XXX is this safe without writer lock? */
|
||||
ep->e_refcnt++;
|
||||
|
||||
/* lru */
|
||||
LRU_DELETE( cache, ep );
|
||||
LRU_ADD( cache, ep );
|
||||
|
||||
/* acquire reader lock */
|
||||
entry_rdwr_lock(ep, 0);
|
||||
|
||||
/* re-check */
|
||||
if ( ep->e_state == ENTRY_STATE_DELETED ||
|
||||
ep->e_state == ENTRY_STATE_CREATING ) {
|
||||
|
||||
/* XXX check that is is required */
|
||||
ep->e_refcnt--;
|
||||
|
||||
/* free reader lock */
|
||||
entry_rdwr_unlock(ep, 0);
|
||||
|
||||
/* free cache mutex */
|
||||
pthread_mutex_unlock( &cache->c_mutex );
|
||||
return( NULL );
|
||||
}
|
||||
|
||||
if ( rw ) {
|
||||
entry_rdwr_unlock(ep, 0);
|
||||
entry_rdwr_lock(ep, 1);
|
||||
}
|
||||
|
||||
/* free cache mutex */
|
||||
pthread_mutex_unlock( &cache->c_mutex );
|
||||
|
||||
return( ep );
|
||||
}
|
||||
|
||||
/* free cache mutex */
|
||||
pthread_mutex_unlock( &cache->c_mutex );
|
||||
|
||||
return( NULL );
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
@ -282,6 +385,11 @@ cache_delete_entry(
|
|||
{
|
||||
int rc;
|
||||
|
||||
Debug( LDAP_DEBUG_TRACE, "====> cache_delete_entry:\n", 0, 0, 0 );
|
||||
|
||||
/* XXX check for writer lock - should also check no readers pending */
|
||||
assert(pthread_rdwr_wchk_np(&e->e_rdwr));
|
||||
|
||||
/* set cache mutex */
|
||||
pthread_mutex_lock( &cache->c_mutex );
|
||||
|
||||
|
|
@ -340,3 +448,4 @@ lru_print( struct cache *cache )
|
|||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -6,8 +6,8 @@
|
|||
#include <sys/socket.h>
|
||||
#include "slap.h"
|
||||
#include "back-ldbm.h"
|
||||
#include "proto-back-ldbm.h"
|
||||
|
||||
extern Entry *dn2entry();
|
||||
extern Attribute *attr_find();
|
||||
|
||||
int
|
||||
|
|
@ -23,33 +23,36 @@ ldbm_back_compare(
|
|||
char *matched;
|
||||
Entry *e;
|
||||
Attribute *a;
|
||||
int i;
|
||||
int i, rc;
|
||||
|
||||
if ( (e = dn2entry( be, dn, &matched )) == NULL ) {
|
||||
/* get entry with reader lock */
|
||||
if ( (e = dn2entry_r( be, dn, &matched )) == NULL ) {
|
||||
send_ldap_result( conn, op, LDAP_NO_SUCH_OBJECT, matched, "" );
|
||||
return( 1 );
|
||||
}
|
||||
|
||||
/* check for deleted */
|
||||
if ( ! access_allowed( be, conn, op, e, ava->ava_type, &ava->ava_value,
|
||||
op->o_dn, ACL_COMPARE ) ) {
|
||||
send_ldap_result( conn, op, LDAP_INSUFFICIENT_ACCESS, "", "" );
|
||||
cache_return_entry( &li->li_cache, e );
|
||||
return( 1 );
|
||||
rc = 1;
|
||||
goto return_results;
|
||||
}
|
||||
|
||||
if ( (a = attr_find( e->e_attrs, ava->ava_type )) == NULL ) {
|
||||
send_ldap_result( conn, op, LDAP_NO_SUCH_ATTRIBUTE, "", "" );
|
||||
cache_return_entry( &li->li_cache, e );
|
||||
return( 1 );
|
||||
rc = 1;
|
||||
goto return_results;
|
||||
}
|
||||
|
||||
if ( value_find( a->a_vals, &ava->ava_value, a->a_syntax, 1 ) == 0 ) {
|
||||
if ( value_find( a->a_vals, &ava->ava_value, a->a_syntax, 1 ) == 0 )
|
||||
send_ldap_result( conn, op, LDAP_COMPARE_TRUE, "", "" );
|
||||
cache_return_entry( &li->li_cache, e );
|
||||
return( 0 );
|
||||
}
|
||||
|
||||
else
|
||||
send_ldap_result( conn, op, LDAP_COMPARE_FALSE, "", "" );
|
||||
cache_return_entry( &li->li_cache, e );
|
||||
return( 0 );
|
||||
|
||||
rc = 0;
|
||||
|
||||
return_results:;
|
||||
cache_return_entry_r( &li->li_cache, e );
|
||||
return( rc );
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,8 +6,8 @@
|
|||
#include <sys/socket.h>
|
||||
#include "slap.h"
|
||||
#include "back-ldbm.h"
|
||||
#include "proto-back-ldbm.h"
|
||||
|
||||
extern Entry *dn2entry();
|
||||
extern Attribute *attr_find();
|
||||
|
||||
int
|
||||
|
|
@ -22,7 +22,12 @@ ldbm_back_delete(
|
|||
char *matched = NULL;
|
||||
Entry *e;
|
||||
|
||||
if ( (e = dn2entry( be, dn, &matched )) == NULL ) {
|
||||
Debug(LDAP_DEBUG_ARGS, "==> ldbm_back_delete: %s\n", dn, 0, 0);
|
||||
|
||||
/* get entry with writer lock */
|
||||
if ( (e = dn2entry_w( be, dn, &matched )) == NULL ) {
|
||||
Debug(LDAP_DEBUG_ARGS, "<=- ldbm_back_delete: no such object %s\n",
|
||||
dn, 0, 0);
|
||||
send_ldap_result( conn, op, LDAP_NO_SUCH_OBJECT, matched, "" );
|
||||
if ( matched != NULL ) {
|
||||
free( matched );
|
||||
|
|
@ -30,38 +35,63 @@ ldbm_back_delete(
|
|||
return( -1 );
|
||||
}
|
||||
|
||||
Debug (LDAP_DEBUG_TRACE,
|
||||
"rdwr_Xchk: readers_reading: %d writer_writing: %d\n",
|
||||
e->e_rdwr.readers_reading, e->e_rdwr.writer_writing, 0);
|
||||
|
||||
/* check for deleted */
|
||||
|
||||
if ( has_children( be, e ) ) {
|
||||
Debug(LDAP_DEBUG_ARGS, "<=- ldbm_back_delete: non leaf %s\n",
|
||||
dn, 0, 0);
|
||||
send_ldap_result( conn, op, LDAP_NOT_ALLOWED_ON_NONLEAF, "",
|
||||
"" );
|
||||
cache_return_entry( &li->li_cache, e );
|
||||
return( -1 );
|
||||
goto error_return;
|
||||
}
|
||||
|
||||
if ( ! access_allowed( be, conn, op, e, "entry", NULL, op->o_dn,
|
||||
ACL_WRITE ) ) {
|
||||
Debug(LDAP_DEBUG_ARGS,
|
||||
"<=- ldbm_back_delete: insufficient access %s\n",
|
||||
dn, 0, 0);
|
||||
send_ldap_result( conn, op, LDAP_INSUFFICIENT_ACCESS, "", "" );
|
||||
cache_return_entry( &li->li_cache, e );
|
||||
return( -1 );
|
||||
goto error_return;
|
||||
}
|
||||
|
||||
Debug (LDAP_DEBUG_TRACE,
|
||||
"rdwr_Xchk: readers_reading: %d writer_writing: %d\n",
|
||||
e->e_rdwr.readers_reading, e->e_rdwr.writer_writing, 0);
|
||||
|
||||
/* XXX delete from parent's id2children entry XXX */
|
||||
|
||||
/* delete from dn2id mapping */
|
||||
if ( dn2id_delete( be, e->e_dn ) != 0 ) {
|
||||
Debug(LDAP_DEBUG_ARGS,
|
||||
"<=- ldbm_back_delete: operations error %s\n",
|
||||
dn, 0, 0);
|
||||
send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR, "", "" );
|
||||
cache_return_entry( &li->li_cache, e );
|
||||
return( -1 );
|
||||
goto error_return;
|
||||
}
|
||||
|
||||
/* delete from disk and cache */
|
||||
if ( id2entry_delete( be, e ) != 0 ) {
|
||||
Debug(LDAP_DEBUG_ARGS,
|
||||
"<=- ldbm_back_delete: operations error %s\n",
|
||||
dn, 0, 0);
|
||||
send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR, "", "" );
|
||||
cache_return_entry( &li->li_cache, e );
|
||||
return( -1 );
|
||||
goto error_return;
|
||||
}
|
||||
cache_return_entry( &li->li_cache, e );
|
||||
|
||||
/* free entry and writer lock */
|
||||
cache_return_entry_w( &li->li_cache, e );
|
||||
|
||||
send_ldap_result( conn, op, LDAP_SUCCESS, "", "" );
|
||||
|
||||
return( 0 );
|
||||
|
||||
error_return:;
|
||||
/* free entry and writer lock */
|
||||
cache_return_entry_w( &li->li_cache, e );
|
||||
|
||||
return( -1 );
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,10 +6,9 @@
|
|||
#include <sys/socket.h>
|
||||
#include "slap.h"
|
||||
#include "back-ldbm.h"
|
||||
#include "proto-back-ldbm.h"
|
||||
|
||||
extern struct dbcache *ldbm_cache_open();
|
||||
extern Entry *cache_find_entry_dn();
|
||||
extern Entry *id2entry();
|
||||
extern char *dn_parent();
|
||||
extern Datum ldbm_cache_fetch();
|
||||
|
||||
|
|
@ -67,7 +66,6 @@ dn2id(
|
|||
{
|
||||
struct ldbminfo *li = (struct ldbminfo *) be->be_private;
|
||||
struct dbcache *db;
|
||||
Entry *e;
|
||||
ID id;
|
||||
Datum key, data;
|
||||
|
||||
|
|
@ -77,17 +75,14 @@ dn2id(
|
|||
#endif
|
||||
|
||||
dn = strdup( dn );
|
||||
dn_normalize_case( dn );
|
||||
Debug( LDAP_DEBUG_TRACE, "=> dn2id( \"%s\" )\n", dn, 0, 0 );
|
||||
dn_normalize_case( dn );
|
||||
|
||||
/* first check the cache */
|
||||
if ( (e = cache_find_entry_dn( &li->li_cache, dn )) != NULL ) {
|
||||
id = e->e_id;
|
||||
if ( (id = cache_find_entry_dn2id( be, &li->li_cache, dn )) != NOID ) {
|
||||
free( dn );
|
||||
Debug( LDAP_DEBUG_TRACE, "<= dn2id %d (in cache)\n", e->e_id,
|
||||
Debug( LDAP_DEBUG_TRACE, "<= dn2id %d (in cache)\n", id,
|
||||
0, 0 );
|
||||
cache_return_entry( &li->li_cache, e );
|
||||
|
||||
return( id );
|
||||
}
|
||||
|
||||
|
|
@ -162,11 +157,12 @@ dn2id_delete(
|
|||
* entry.
|
||||
*/
|
||||
|
||||
Entry *
|
||||
static Entry *
|
||||
dn2entry(
|
||||
Backend *be,
|
||||
char *dn,
|
||||
char **matched
|
||||
char **matched,
|
||||
int rw
|
||||
)
|
||||
{
|
||||
struct ldbminfo *li = (struct ldbminfo *) be->be_private;
|
||||
|
|
@ -174,8 +170,12 @@ dn2entry(
|
|||
Entry *e;
|
||||
char *pdn;
|
||||
|
||||
if ( (id = dn2id( be, dn )) != NOID && (e = id2entry( be, id ))
|
||||
!= NULL ) {
|
||||
Debug(LDAP_DEBUG_TRACE, "dn2entry_%s: dn: %s\n",
|
||||
rw ? "w" : "r", dn, 0);
|
||||
|
||||
if ( (id = dn2id( be, dn )) != NOID &&
|
||||
(e = id2entry( be, id, rw )) != NULL )
|
||||
{
|
||||
return( e );
|
||||
}
|
||||
*matched = NULL;
|
||||
|
|
@ -187,9 +187,11 @@ dn2entry(
|
|||
|
||||
/* entry does not exist - see how much of the dn does exist */
|
||||
if ( (pdn = dn_parent( be, dn )) != NULL ) {
|
||||
if ( (e = dn2entry( be, pdn, matched )) != NULL ) {
|
||||
/* get entry with reader lock */
|
||||
if ( (e = dn2entry_r( be, pdn, matched )) != NULL ) {
|
||||
*matched = pdn;
|
||||
cache_return_entry( &li->li_cache, e );
|
||||
/* free entry with reader lock */
|
||||
cache_return_entry_r( &li->li_cache, e );
|
||||
} else {
|
||||
free( pdn );
|
||||
}
|
||||
|
|
@ -197,3 +199,39 @@ dn2entry(
|
|||
|
||||
return( NULL );
|
||||
}
|
||||
|
||||
#if 0
|
||||
if (e->e_state == ENTRY_STATE_DELETED)
|
||||
continue;
|
||||
|
||||
if (strcmp(dn, e->e_dn) != 0)
|
||||
continue;
|
||||
|
||||
/* return locked entry entry */
|
||||
return(e);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
Entry *
|
||||
dn2entry_r(
|
||||
Backend *be,
|
||||
char *dn,
|
||||
char **matched
|
||||
)
|
||||
{
|
||||
return( dn2entry( be, dn, matched, 0 ) );
|
||||
}
|
||||
|
||||
Entry *
|
||||
dn2entry_w(
|
||||
Backend *be,
|
||||
char *dn,
|
||||
char **matched
|
||||
)
|
||||
{
|
||||
return( dn2entry( be, dn, matched, 1 ) );
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -6,8 +6,8 @@
|
|||
#include <sys/socket.h>
|
||||
#include "slap.h"
|
||||
#include "back-ldbm.h"
|
||||
#include "proto-back-ldbm.h"
|
||||
|
||||
extern Entry *dn2entry();
|
||||
extern Attribute *attr_find();
|
||||
|
||||
|
||||
|
|
@ -30,18 +30,19 @@ ldbm_back_group(
|
|||
Attribute *uniqueMember;
|
||||
int rc;
|
||||
|
||||
Debug( LDAP_DEBUG_TRACE, "ldbm_back_group: bdn: %s\n", bdn, 0, 0 );
|
||||
Debug( LDAP_DEBUG_TRACE, "ldbm_back_group: edn: %s\n", edn, 0, 0 );
|
||||
Debug( LDAP_DEBUG_TRACE, "=> ldbm_back_group: bdn: %s\n", bdn, 0, 0 );
|
||||
Debug( LDAP_DEBUG_TRACE, "=> ldbm_back_group: edn: %s\n", edn, 0, 0 );
|
||||
|
||||
/* can we find bdn entry */
|
||||
if ((e = dn2entry(be, bdn, &matched )) == NULL) {
|
||||
Debug( LDAP_DEBUG_TRACE, "ldbm_back_group: cannot find bdn: %s matched: %x\n", bdn, matched, 0 );
|
||||
/* can we find bdn entry with reader lock */
|
||||
if ((e = dn2entry_r(be, bdn, &matched )) == NULL) {
|
||||
Debug( LDAP_DEBUG_TRACE, "=> ldbm_back_group: cannot find bdn: %s matched: %x\n", bdn, matched, 0 );
|
||||
if (matched != NULL)
|
||||
free(matched);
|
||||
return( 1 );
|
||||
}
|
||||
Debug( LDAP_DEBUG_ARGS, "ldbm_back_group: found bdn: %s matched: %x\n", bdn, matched, 0 );
|
||||
Debug( LDAP_DEBUG_ARGS, "=> ldbm_back_group: found bdn: %s matched: %x\n", bdn, matched, 0 );
|
||||
|
||||
/* check for deleted */
|
||||
|
||||
/* find it's objectClass and uniqueMember attribute values
|
||||
* make sure this is a group entry
|
||||
|
|
@ -50,16 +51,16 @@ ldbm_back_group(
|
|||
|
||||
rc = 1;
|
||||
if ((objectClass = attr_find(e->e_attrs, "objectclass")) == NULL) {
|
||||
Debug( LDAP_DEBUG_TRACE, "ldbm_back_group: failed to find objectClass\n", 0, 0, 0 );
|
||||
Debug( LDAP_DEBUG_TRACE, "<= ldbm_back_group: failed to find objectClass\n", 0, 0, 0 );
|
||||
}
|
||||
else if ((uniqueMember = attr_find(e->e_attrs, "uniquemember")) == NULL) {
|
||||
Debug( LDAP_DEBUG_TRACE, "ldbm_back_group: failed to find uniqueMember\n", 0, 0, 0 );
|
||||
Debug( LDAP_DEBUG_TRACE, "<= ldbm_back_group: failed to find uniqueMember\n", 0, 0, 0 );
|
||||
}
|
||||
else {
|
||||
struct berval bvObjectClass;
|
||||
struct berval bvUniqueMembers;
|
||||
|
||||
Debug( LDAP_DEBUG_ARGS, "ldbm_back_group: found objectClass and uniqueMembers\n", 0, 0, 0 );
|
||||
Debug( LDAP_DEBUG_ARGS, "<= ldbm_back_group: found objectClass and uniqueMembers\n", 0, 0, 0 );
|
||||
|
||||
bvObjectClass.bv_val = "groupofuniquenames";
|
||||
bvObjectClass.bv_len = strlen( bvObjectClass.bv_val );
|
||||
|
|
@ -67,22 +68,22 @@ ldbm_back_group(
|
|||
bvUniqueMembers.bv_len = strlen( edn );
|
||||
|
||||
if (value_find(objectClass->a_vals, &bvObjectClass, SYNTAX_CIS, 1) != 0) {
|
||||
Debug( LDAP_DEBUG_TRACE, "ldbm_back_group: failed to find objectClass in groupOfUniqueNames\n",
|
||||
Debug( LDAP_DEBUG_TRACE, "<= ldbm_back_group: failed to find objectClass in groupOfUniqueNames\n",
|
||||
0, 0, 0 );
|
||||
}
|
||||
else if (value_find(uniqueMember->a_vals, &bvUniqueMembers, SYNTAX_CIS, 1) != 0) {
|
||||
Debug( LDAP_DEBUG_ACL, "ldbm_back_group: %s not in %s: groupOfUniqueNames\n",
|
||||
Debug( LDAP_DEBUG_ACL, "<= ldbm_back_group: %s not in %s: groupOfUniqueNames\n",
|
||||
edn, bdn, 0 );
|
||||
}
|
||||
else {
|
||||
Debug( LDAP_DEBUG_ACL, "ldbm_back_group: %s is in %s: groupOfUniqueNames\n",
|
||||
Debug( LDAP_DEBUG_ACL, "<= ldbm_back_group: %s is in %s: groupOfUniqueNames\n",
|
||||
edn, bdn, 0 );
|
||||
rc = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/* free e */
|
||||
cache_return_entry( &li->li_cache, e );
|
||||
/* free entry and reader lock */
|
||||
cache_return_entry_r( &li->li_cache, e );
|
||||
Debug( LDAP_DEBUG_ARGS, "ldbm_back_group: rc: %d\n", rc, 0, 0 );
|
||||
return(rc);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,7 +10,6 @@ extern struct dbcache *ldbm_cache_open();
|
|||
extern Datum ldbm_cache_fetch();
|
||||
extern char *dn_parent();
|
||||
extern Entry *str2entry();
|
||||
extern Entry *cache_find_entry_id();
|
||||
extern char *entry2str();
|
||||
extern pthread_mutex_t entry2str_mutex;
|
||||
|
||||
|
|
@ -55,6 +54,8 @@ id2entry_add( Backend *be, Entry *e )
|
|||
(void) cache_add_entry_lock( &li->li_cache, e, 0 );
|
||||
|
||||
Debug( LDAP_DEBUG_TRACE, "<= id2entry_add %d\n", rc, 0, 0 );
|
||||
|
||||
/* XXX should entries be born locked, i.e. apply writer lock here? */
|
||||
return( rc );
|
||||
}
|
||||
|
||||
|
|
@ -66,12 +67,20 @@ id2entry_delete( Backend *be, Entry *e )
|
|||
Datum key;
|
||||
int rc;
|
||||
|
||||
Debug( LDAP_DEBUG_TRACE, "=> id2entry_delete( %d, \"%s\" )\n", e->e_id,
|
||||
e->e_dn, 0 );
|
||||
|
||||
/* XXX - check for writer lock - should also check no reader pending */
|
||||
assert(pthread_rdwr_wchk_np(&e->e_rdwr));
|
||||
|
||||
#ifdef LDBM_USE_DB2
|
||||
memset( &key, 0, sizeof( key ) );
|
||||
#endif
|
||||
|
||||
Debug( LDAP_DEBUG_TRACE, "=> id2entry_delete( %d, \"%s\" )\n", e->e_id,
|
||||
e->e_dn, 0 );
|
||||
/* XXX - check for writer lock - should also check no reader pending */
|
||||
Debug (LDAP_DEBUG_TRACE,
|
||||
"rdwr_Xchk: readers_reading: %d writer_writing: %d\n",
|
||||
e->e_rdwr.readers_reading, e->e_rdwr.writer_writing, 0);
|
||||
|
||||
if ( (db = ldbm_cache_open( be, "id2entry", LDBM_SUFFIX, LDBM_WRCREAT ))
|
||||
== NULL ) {
|
||||
|
|
@ -96,8 +105,9 @@ id2entry_delete( Backend *be, Entry *e )
|
|||
return( rc );
|
||||
}
|
||||
|
||||
/* XXX returns entry with reader/writer lock */
|
||||
Entry *
|
||||
id2entry( Backend *be, ID id )
|
||||
id2entry( Backend *be, ID id, int rw )
|
||||
{
|
||||
struct ldbminfo *li = (struct ldbminfo *) be->be_private;
|
||||
struct dbcache *db;
|
||||
|
|
@ -109,11 +119,12 @@ id2entry( Backend *be, ID id )
|
|||
memset( &data, 0, sizeof( data ) );
|
||||
#endif
|
||||
|
||||
Debug( LDAP_DEBUG_TRACE, "=> id2entry( %ld )\n", id, 0, 0 );
|
||||
Debug( LDAP_DEBUG_TRACE, "=> id2entry_%s( %ld )\n",
|
||||
rw ? "w" : "r", id, 0 );
|
||||
|
||||
if ( (e = cache_find_entry_id( &li->li_cache, id )) != NULL ) {
|
||||
Debug( LDAP_DEBUG_TRACE, "<= id2entry 0x%x (cache)\n", e, 0,
|
||||
0 );
|
||||
if ( (e = cache_find_entry_id( &li->li_cache, id, rw )) != NULL ) {
|
||||
Debug( LDAP_DEBUG_TRACE, "<= id2entry_%s 0x%x (cache)\n",
|
||||
rw ? "w" : "r", e, 0 );
|
||||
return( e );
|
||||
}
|
||||
|
||||
|
|
@ -130,20 +141,47 @@ id2entry( Backend *be, ID id )
|
|||
data = ldbm_cache_fetch( db, key );
|
||||
|
||||
if ( data.dptr == NULL ) {
|
||||
Debug( LDAP_DEBUG_TRACE, "<= id2entry( %ld ) not found\n", id,
|
||||
0, 0 );
|
||||
Debug( LDAP_DEBUG_TRACE, "<= id2entry_%s( %ld ) not found\n",
|
||||
rw ? "w" : "r", id, 0 );
|
||||
ldbm_cache_close( be, db );
|
||||
return( NULL );
|
||||
}
|
||||
|
||||
if ( (e = str2entry( data.dptr )) != NULL ) {
|
||||
e->e_id = id;
|
||||
(void) cache_add_entry_lock( &li->li_cache, e, 0 );
|
||||
}
|
||||
e = str2entry( data.dptr );
|
||||
|
||||
ldbm_datum_free( db->dbc_db, data );
|
||||
ldbm_cache_close( be, db );
|
||||
|
||||
Debug( LDAP_DEBUG_TRACE, "<= id2entry( %ld ) 0x%x (disk)\n", id, e, 0 );
|
||||
if ( e == NULL ) {
|
||||
Debug( LDAP_DEBUG_TRACE, "<= id2entry_%s( %ld ) (failed)\n",
|
||||
rw ? "w" : "r", id, 0 );
|
||||
return( NULL );
|
||||
}
|
||||
|
||||
/* acquire required reader/writer lock */
|
||||
if (entry_rdwr_lock(e, rw)) {
|
||||
/* XXX set DELETE flag?? */
|
||||
entry_free(e);
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
e->e_id = id;
|
||||
(void) cache_add_entry_lock( &li->li_cache, e, 0 );
|
||||
|
||||
Debug( LDAP_DEBUG_TRACE, "<= id2entry_%s( %ld ) (disk)\n",
|
||||
rw ? "w" : "r", id, 0 );
|
||||
return( e );
|
||||
}
|
||||
|
||||
Entry *
|
||||
id2entry_r( Backend *be, ID id )
|
||||
{
|
||||
return( id2entry( be, id, 0 ) );
|
||||
}
|
||||
|
||||
Entry *
|
||||
id2entry_2( Backend *be, ID id )
|
||||
{
|
||||
return( id2entry( be, id, 1 ) );
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -17,7 +17,6 @@
|
|||
#define LDAP_KRB_PRINCIPAL "ldapserver"
|
||||
|
||||
extern char *ldap_srvtab;
|
||||
extern Entry *dn2entry();
|
||||
extern Attribute *attr_find();
|
||||
|
||||
krbv4_ldap_auth(
|
||||
|
|
|
|||
|
|
@ -6,9 +6,9 @@
|
|||
#include <sys/socket.h>
|
||||
#include "slap.h"
|
||||
#include "back-ldbm.h"
|
||||
#include "proto-back-ldbm.h"
|
||||
|
||||
extern int global_schemacheck;
|
||||
extern Entry *dn2entry();
|
||||
extern Attribute *attr_find();
|
||||
|
||||
static int add_values();
|
||||
|
|
@ -30,7 +30,9 @@ ldbm_back_modify(
|
|||
int i, err, modtype;
|
||||
LDAPMod *mod;
|
||||
|
||||
if ( (e = dn2entry( be, dn, &matched )) == NULL ) {
|
||||
Debug(LDAP_DEBUG_ARGS, "ldbm_back_modify:\n", 0, 0, 0);
|
||||
|
||||
if ( (e = dn2entry_w( be, dn, &matched )) == NULL ) {
|
||||
send_ldap_result( conn, op, LDAP_NO_SUCH_OBJECT, matched,
|
||||
NULL );
|
||||
if ( matched != NULL ) {
|
||||
|
|
@ -38,12 +40,14 @@ ldbm_back_modify(
|
|||
}
|
||||
return( -1 );
|
||||
}
|
||||
|
||||
/* check for deleted */
|
||||
|
||||
/* lock entry */
|
||||
|
||||
if ( (err = acl_check_mods( be, conn, op, e, mods )) != LDAP_SUCCESS ) {
|
||||
send_ldap_result( conn, op, err, NULL, NULL );
|
||||
cache_return_entry( &li->li_cache, e );
|
||||
return( -1 );
|
||||
goto error_return;
|
||||
}
|
||||
|
||||
for ( mod = mods; mod != NULL; mod = mod->mod_next ) {
|
||||
|
|
@ -68,6 +72,13 @@ ldbm_back_modify(
|
|||
}
|
||||
}
|
||||
|
||||
/* check that the entry still obeys the schema */
|
||||
if ( global_schemacheck && oc_schema_check( e ) != 0 ) {
|
||||
Debug( LDAP_DEBUG_ANY, "entry failed schema check\n", 0, 0, 0 );
|
||||
send_ldap_result( conn, op, LDAP_OBJECT_CLASS_VIOLATION, NULL, NULL );
|
||||
goto error_return;
|
||||
}
|
||||
|
||||
/* check for abandon */
|
||||
pthread_mutex_lock( &op->o_abandonmutex );
|
||||
if ( op->o_abandon ) {
|
||||
|
|
@ -76,13 +87,6 @@ ldbm_back_modify(
|
|||
}
|
||||
pthread_mutex_unlock( &op->o_abandonmutex );
|
||||
|
||||
/* check that the entry still obeys the schema */
|
||||
if ( global_schemacheck && oc_schema_check( e ) != 0 ) {
|
||||
Debug( LDAP_DEBUG_ANY, "entry failed schema check\n", 0, 0, 0 );
|
||||
send_ldap_result( conn, op, LDAP_OBJECT_CLASS_VIOLATION, NULL, NULL );
|
||||
goto error_return;
|
||||
}
|
||||
|
||||
/* modify indexes */
|
||||
if ( index_add_mods( be, mods, e->e_id ) != 0 ) {
|
||||
send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR, NULL, NULL );
|
||||
|
|
@ -104,14 +108,11 @@ ldbm_back_modify(
|
|||
}
|
||||
|
||||
send_ldap_result( conn, op, LDAP_SUCCESS, NULL, NULL );
|
||||
cache_return_entry( &li->li_cache, e );
|
||||
|
||||
cache_return_entry_w( &li->li_cache, e );
|
||||
return( 0 );
|
||||
|
||||
error_return:;
|
||||
cache_delete_entry( &li->li_cache, e );
|
||||
cache_return_entry( &li->li_cache, e );
|
||||
|
||||
cache_return_entry_w( &li->li_cache, e );
|
||||
return( -1 );
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -6,8 +6,8 @@
|
|||
#include <sys/socket.h>
|
||||
#include "slap.h"
|
||||
#include "back-ldbm.h"
|
||||
#include "proto-back-ldbm.h"
|
||||
|
||||
extern Entry *dn2entry();
|
||||
extern char *dn_parent();
|
||||
|
||||
int
|
||||
|
|
@ -24,10 +24,12 @@ ldbm_back_modrdn(
|
|||
char *matched;
|
||||
char *pdn, *newdn, *p;
|
||||
char sep[2];
|
||||
Entry *e, *e2;
|
||||
Entry *e;
|
||||
|
||||
matched = NULL;
|
||||
if ( (e = dn2entry( be, dn, &matched )) == NULL ) {
|
||||
|
||||
/* get entry with writer lock */
|
||||
if ( (e = dn2entry_w( be, dn, &matched )) == NULL ) {
|
||||
send_ldap_result( conn, op, LDAP_NO_SUCH_OBJECT, matched, "" );
|
||||
if ( matched != NULL ) {
|
||||
free( matched );
|
||||
|
|
@ -61,17 +63,12 @@ ldbm_back_modrdn(
|
|||
}
|
||||
(void) dn_normalize( newdn );
|
||||
|
||||
matched = NULL;
|
||||
if ( (e2 = dn2entry( be, newdn, &matched )) != NULL ) {
|
||||
/* get entry with writer lock */
|
||||
if ( (dn2id ( be, newdn ) ) != NOID ) {
|
||||
free( newdn );
|
||||
free( pdn );
|
||||
send_ldap_result( conn, op, LDAP_ALREADY_EXISTS, NULL, NULL );
|
||||
cache_return_entry( &li->li_cache, e2 );
|
||||
cache_return_entry( &li->li_cache, e );
|
||||
return( -1 );
|
||||
}
|
||||
if ( matched != NULL ) {
|
||||
free( matched );
|
||||
goto error_return;
|
||||
}
|
||||
|
||||
/* check for abandon */
|
||||
|
|
@ -80,9 +77,7 @@ ldbm_back_modrdn(
|
|||
pthread_mutex_unlock( &op->o_abandonmutex );
|
||||
free( newdn );
|
||||
free( pdn );
|
||||
cache_return_entry( &li->li_cache, e2 );
|
||||
cache_return_entry( &li->li_cache, e );
|
||||
return( -1 );
|
||||
goto error_return;
|
||||
}
|
||||
pthread_mutex_unlock( &op->o_abandonmutex );
|
||||
|
||||
|
|
@ -91,8 +86,7 @@ ldbm_back_modrdn(
|
|||
free( newdn );
|
||||
free( pdn );
|
||||
send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR, NULL, NULL );
|
||||
cache_return_entry( &li->li_cache, e );
|
||||
return( -1 );
|
||||
goto error_return;
|
||||
}
|
||||
|
||||
/* delete old one */
|
||||
|
|
@ -100,8 +94,7 @@ ldbm_back_modrdn(
|
|||
free( newdn );
|
||||
free( pdn );
|
||||
send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR, NULL, NULL );
|
||||
cache_return_entry( &li->li_cache, e );
|
||||
return( -1 );
|
||||
goto error_return;
|
||||
}
|
||||
|
||||
(void) cache_delete_entry( &li->li_cache, e );
|
||||
|
|
@ -120,13 +113,19 @@ ldbm_back_modrdn(
|
|||
/* id2entry index */
|
||||
if ( id2entry_add( be, e ) != 0 ) {
|
||||
entry_free( e );
|
||||
|
||||
send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR, "", "" );
|
||||
return( -1 );
|
||||
goto error_return;
|
||||
}
|
||||
free( pdn );
|
||||
cache_return_entry( &li->li_cache, e );
|
||||
|
||||
/* free entry and writer lock */
|
||||
cache_return_entry_w( &li->li_cache, e );
|
||||
send_ldap_result( conn, op, LDAP_SUCCESS, NULL, NULL );
|
||||
|
||||
return( 0 );
|
||||
|
||||
error_return:
|
||||
/* free entry and writer lock */
|
||||
cache_return_entry_w( &li->li_cache, e );
|
||||
return( -1 );
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,10 +15,11 @@ void attr_index_config( struct ldbminfo *li, char *fname, int lineno,
|
|||
*/
|
||||
|
||||
void cache_set_state( struct cache *cache, Entry *e, int state );
|
||||
void cache_return_entry( struct cache *cache, Entry *e );
|
||||
void cache_return_entry_r( struct cache *cache, Entry *e );
|
||||
void cache_return_entry_w( struct cache *cache, Entry *e );
|
||||
int cache_add_entry_lock( struct cache *cache, Entry *e, int state );
|
||||
Entry * cache_find_entry_dn( struct cache *cache, char *dn );
|
||||
Entry * cache_find_entry_id( struct cache *cache, ID id );
|
||||
ID cache_find_entry_dn2id( Backend *be, struct cache *cache, char *dn );
|
||||
Entry * cache_find_entry_id( struct cache *cache, ID id, int rw );
|
||||
int cache_delete_entry( struct cache *cache, Entry *e );
|
||||
|
||||
/*
|
||||
|
|
@ -40,7 +41,9 @@ int ldbm_cache_delete( struct dbcache *db, Datum key );
|
|||
int dn2id_add( Backend *be, char *dn, ID id );
|
||||
ID dn2id( Backend *be, char *dn );
|
||||
int dn2id_delete( Backend *be, char *dn );
|
||||
Entry * dn2entry( Backend *be, char *dn, char **matched );
|
||||
/*Entry * dn2entry( Backend *be, char *dn, char **matched );*/
|
||||
Entry * dn2entry_r( Backend *be, char *dn, char **matched );
|
||||
Entry * dn2entry_w( Backend *be, char *dn, char **matched );
|
||||
|
||||
/*
|
||||
* filterindex.c
|
||||
|
|
@ -61,7 +64,9 @@ int has_children( Backend *be, Entry *p );
|
|||
|
||||
int id2entry_add( Backend *be, Entry *e );
|
||||
int id2entry_delete( Backend *be, Entry *e );
|
||||
Entry * id2entry( Backend *be, ID id );
|
||||
Entry * id2entry( Backend *be, ID id, int rw );
|
||||
Entry * id2entry_r( Backend *be, ID id );
|
||||
Entry * id2entry_w( Backend *be, ID id );
|
||||
|
||||
/*
|
||||
* idl.c
|
||||
|
|
|
|||
|
|
@ -6,14 +6,12 @@
|
|||
#include <sys/socket.h>
|
||||
#include "slap.h"
|
||||
#include "back-ldbm.h"
|
||||
#include "proto-back-ldbm.h"
|
||||
|
||||
extern time_t currenttime;
|
||||
extern pthread_mutex_t currenttime_mutex;
|
||||
|
||||
extern ID dn2id();
|
||||
extern IDList *idl_alloc();
|
||||
extern Entry *id2entry();
|
||||
extern Entry *dn2entry();
|
||||
extern Attribute *attr_find();
|
||||
extern IDList *filter_candidates();
|
||||
extern char *ch_realloc();
|
||||
|
|
@ -62,6 +60,8 @@ ldbm_back_search(
|
|||
char *rbuf, *rcur, *r;
|
||||
int nentries = 0;
|
||||
|
||||
Debug(LDAP_DEBUG_ARGS, "=> ldbm_back_search\n", 0, 0, 0);
|
||||
|
||||
if ( tlimit == 0 && be_isroot( be, op->o_dn ) ) {
|
||||
tlimit = -1; /* allow root to set no limit */
|
||||
} else {
|
||||
|
|
@ -139,10 +139,9 @@ ldbm_back_search(
|
|||
}
|
||||
pthread_mutex_unlock( ¤ttime_mutex );
|
||||
|
||||
/* get the entry */
|
||||
if ( (e = id2entry( be, id )) == NULL ) {
|
||||
Debug( LDAP_DEBUG_ARGS, "candidate %d not found\n", id,
|
||||
0, 0 );
|
||||
/* get the entry with reader lock */
|
||||
if ( (e = id2entry_r( be, id )) == NULL ) {
|
||||
Debug( LDAP_DEBUG_ARGS, "candidate %d not found\n", id, 0, 0 );
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
@ -200,7 +199,7 @@ ldbm_back_search(
|
|||
if ( scopeok ) {
|
||||
/* check size limit */
|
||||
if ( --slimit == -1 ) {
|
||||
cache_return_entry( &li->li_cache, e );
|
||||
cache_return_entry_r( &li->li_cache, e );
|
||||
send_ldap_search_result( conn, op,
|
||||
LDAP_SIZELIMIT_EXCEEDED, NULL,
|
||||
nrefs > 0 ? rbuf : NULL, nentries );
|
||||
|
|
@ -217,7 +216,7 @@ ldbm_back_search(
|
|||
case 1: /* entry not sent */
|
||||
break;
|
||||
case -1: /* connection closed */
|
||||
cache_return_entry( &li->li_cache, e );
|
||||
cache_return_entry_r( &li->li_cache, e );
|
||||
idl_free( candidates );
|
||||
free( rbuf );
|
||||
return( 0 );
|
||||
|
|
@ -226,7 +225,10 @@ ldbm_back_search(
|
|||
}
|
||||
}
|
||||
|
||||
cache_return_entry( &li->li_cache, e );
|
||||
if( e == NULL ) {
|
||||
/* free reader lock */
|
||||
cache_return_entry_r( &li->li_cache, e );
|
||||
}
|
||||
|
||||
pthread_yield();
|
||||
}
|
||||
|
|
@ -262,16 +264,24 @@ base_candidates(
|
|||
IDList *idl;
|
||||
Entry *e;
|
||||
|
||||
Debug(LDAP_DEBUG_TRACE, "base_candidates: base: %s\n", base, 0, 0);
|
||||
|
||||
*err = LDAP_SUCCESS;
|
||||
if ( (e = dn2entry( be, base, matched )) == NULL ) {
|
||||
|
||||
/* get entry with reader lock */
|
||||
if ( (e = dn2entry_r( be, base, matched )) == NULL ) {
|
||||
*err = LDAP_NO_SUCH_OBJECT;
|
||||
return( NULL );
|
||||
}
|
||||
|
||||
/* check for deleted */
|
||||
|
||||
idl = idl_alloc( 1 );
|
||||
idl_insert( &idl, e->e_id, 1 );
|
||||
|
||||
cache_return_entry( &li->li_cache, e );
|
||||
|
||||
/* free reader lock */
|
||||
cache_return_entry_r( &li->li_cache, e );
|
||||
|
||||
return( idl );
|
||||
}
|
||||
|
|
@ -295,11 +305,14 @@ onelevel_candidates(
|
|||
char buf[20];
|
||||
IDList *candidates;
|
||||
|
||||
Debug(LDAP_DEBUG_TRACE, "onelevel_candidates: base: %s\n", base, 0, 0);
|
||||
|
||||
*err = LDAP_SUCCESS;
|
||||
e = NULL;
|
||||
/* get the base object */
|
||||
if ( base != NULL && *base != '\0' && (e = dn2entry( be, base,
|
||||
matched )) == NULL ) {
|
||||
/* get the base object with reader lock */
|
||||
if ( base != NULL && *base != '\0' &&
|
||||
(e = dn2entry_r( be, base, matched )) == NULL )
|
||||
{
|
||||
*err = LDAP_NO_SUCH_OBJECT;
|
||||
return( NULL );
|
||||
}
|
||||
|
|
@ -329,6 +342,8 @@ onelevel_candidates(
|
|||
f->f_and->f_next = NULL;
|
||||
filter_free( f );
|
||||
|
||||
/* free entry and reader lock */
|
||||
cache_return_entry_r( &li->li_cache, e );
|
||||
return( candidates );
|
||||
}
|
||||
|
||||
|
|
@ -351,6 +366,9 @@ subtree_candidates(
|
|||
Filter *f;
|
||||
IDList *candidates;
|
||||
|
||||
Debug(LDAP_DEBUG_TRACE, "subtree_candidates: base: %s\n",
|
||||
base ? base : "NULL", 0, 0);
|
||||
|
||||
/*
|
||||
* get the base object - unless we already have it (from one-level).
|
||||
* also, unless this is a one-level search or a subtree search
|
||||
|
|
@ -365,12 +383,17 @@ subtree_candidates(
|
|||
*err = LDAP_SUCCESS;
|
||||
f = NULL;
|
||||
if ( lookupbase ) {
|
||||
if ( base != NULL && *base != '\0' && (e = dn2entry( be, base,
|
||||
matched )) == NULL ) {
|
||||
if ( base != NULL && *base != '\0' &&
|
||||
(e = dn2entry_r( be, base, matched )) == NULL )
|
||||
{
|
||||
*err = LDAP_NO_SUCH_OBJECT;
|
||||
return( NULL );
|
||||
}
|
||||
|
||||
if (e) {
|
||||
cache_return_entry_r( &li->li_cache, e );
|
||||
}
|
||||
|
||||
f = (Filter *) ch_malloc( sizeof(Filter) );
|
||||
f->f_next = NULL;
|
||||
f->f_choice = LDAP_FILTER_OR;
|
||||
|
|
@ -407,9 +430,5 @@ subtree_candidates(
|
|||
filter_free( f );
|
||||
}
|
||||
|
||||
if ( e != NULL ) {
|
||||
cache_return_entry( &li->li_cache, e );
|
||||
}
|
||||
|
||||
return( candidates );
|
||||
}
|
||||
|
|
|
|||
|
|
@ -40,6 +40,9 @@ config_info( Connection *conn, Operation *op )
|
|||
vals[1] = NULL;
|
||||
|
||||
e = (Entry *) ch_calloc( 1, sizeof(Entry) );
|
||||
/* initialize reader/writer lock */
|
||||
entry_rdwr_init(e);
|
||||
|
||||
e->e_attrs = NULL;
|
||||
e->e_dn = strdup( SLAPD_CONFIG_DN );
|
||||
|
||||
|
|
|
|||
|
|
@ -195,6 +195,9 @@ slapd_daemon(
|
|||
FD_ZERO( &readfds );
|
||||
FD_SET( tcps, &readfds );
|
||||
|
||||
zero.tv_sec = 0;
|
||||
zero.tv_usec = 0;
|
||||
|
||||
pthread_mutex_lock( &active_threads_mutex );
|
||||
Debug( LDAP_DEBUG_CONNS,
|
||||
"listening for connections on %d, activity on:",
|
||||
|
|
@ -215,8 +218,6 @@ slapd_daemon(
|
|||
Debug( LDAP_DEBUG_CONNS, "\n", 0, 0, 0 );
|
||||
pthread_mutex_unlock( &new_conn_mutex );
|
||||
|
||||
zero.tv_sec = 0;
|
||||
zero.tv_usec = 0;
|
||||
Debug( LDAP_DEBUG_CONNS, "before select active_threads %d\n",
|
||||
active_threads, 0, 0 );
|
||||
#if defined(PTHREAD_PREEMPTIVE) || defined(NO_THREADS)
|
||||
|
|
|
|||
|
|
@ -43,9 +43,12 @@ str2entry( char *s )
|
|||
* or newline.
|
||||
*/
|
||||
|
||||
Debug( LDAP_DEBUG_TRACE, "=> str2entry\n", s, 0, 0 );
|
||||
Debug( LDAP_DEBUG_TRACE, "=> str2entry\n",
|
||||
s ? s : "NULL", 0, 0 );
|
||||
|
||||
e = (Entry *) ch_calloc( 1, sizeof(Entry) );
|
||||
/* initialize reader/writer lock */
|
||||
entry_rdwr_init(e);
|
||||
|
||||
/* check to see if there's an id included */
|
||||
next = s;
|
||||
|
|
@ -112,6 +115,7 @@ str2entry( char *s )
|
|||
}
|
||||
|
||||
Debug( LDAP_DEBUG_TRACE, "<= str2entry 0x%x\n", e, 0, 0 );
|
||||
|
||||
return( e );
|
||||
}
|
||||
|
||||
|
|
@ -187,6 +191,10 @@ entry_free( Entry *e )
|
|||
int i;
|
||||
Attribute *a, *next;
|
||||
|
||||
/* XXX check that no reader/writer locks exist */
|
||||
assert( !pthread_rdwr_wchk_np(&e->e_rdwr) &&
|
||||
!pthread_rdwr_rchk_np(&e->e_rdwr) );
|
||||
|
||||
if ( e->e_dn != NULL ) {
|
||||
free( e->e_dn );
|
||||
}
|
||||
|
|
@ -196,3 +204,56 @@ entry_free( Entry *e )
|
|||
}
|
||||
free( e );
|
||||
}
|
||||
|
||||
int
|
||||
entry_rdwr_lock(Entry *e, int rw)
|
||||
{
|
||||
Debug( LDAP_DEBUG_ARGS, "entry_rdwr_%slock: ID: %ld\n",
|
||||
rw ? "w" : "r", e->e_id, 0);
|
||||
if (rw)
|
||||
return pthread_rdwr_wlock_np(&e->e_rdwr);
|
||||
else
|
||||
return pthread_rdwr_rlock_np(&e->e_rdwr);
|
||||
}
|
||||
|
||||
int
|
||||
entry_rdwr_rlock(Entry *e)
|
||||
{
|
||||
return entry_rdwr_lock( e, 0 );
|
||||
}
|
||||
|
||||
int
|
||||
entry_rdwr_wlock(Entry *e)
|
||||
{
|
||||
return entry_rdwr_lock( e, 1 );
|
||||
}
|
||||
|
||||
int
|
||||
entry_rdwr_unlock(Entry *e, int rw)
|
||||
{
|
||||
Debug( LDAP_DEBUG_ARGS, "entry_rdwr_%sunlock: ID: %ld\n",
|
||||
rw ? "w" : "r", e->e_id, 0);
|
||||
if (rw)
|
||||
return pthread_rdwr_wunlock_np(&e->e_rdwr);
|
||||
else
|
||||
return pthread_rdwr_runlock_np(&e->e_rdwr);
|
||||
}
|
||||
|
||||
int
|
||||
entry_rdwr_runlock(Entry *e)
|
||||
{
|
||||
return entry_rdwr_unlock( e, 0 );
|
||||
}
|
||||
|
||||
int
|
||||
entry_rdwr_wunlock(Entry *e)
|
||||
{
|
||||
return entry_rdwr_unlock( e, 1 );
|
||||
}
|
||||
|
||||
int
|
||||
entry_rdwr_init(Entry *e)
|
||||
{
|
||||
return pthread_rdwr_init_np(&e->e_rdwr, NULL);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -60,6 +60,8 @@ monitor_info( Connection *conn, Operation *op )
|
|||
vals[1] = NULL;
|
||||
|
||||
e = (Entry *) ch_calloc( 1, sizeof(Entry) );
|
||||
/* initialize reader/writer lock */
|
||||
entry_rdwr_init(e);
|
||||
e->e_attrs = NULL;
|
||||
e->e_dn = strdup( SLAPD_MONITOR_DN );
|
||||
|
||||
|
|
|
|||
|
|
@ -107,6 +107,14 @@ Entry * str2entry( char *s );
|
|||
char * entry2str( Entry *e, int *len, int printid );
|
||||
void entry_free( Entry *e );
|
||||
|
||||
int entry_rdwr_lock( Entry *e, int rw );
|
||||
int entry_rdwr_rlock( Entry *e );
|
||||
int entry_rdwr_wlock( Entry *e );
|
||||
int entry_rdwr_unlock( Entry *e, int rw );
|
||||
int entry_rdwr_runlock( Entry *e );
|
||||
int entry_rdwr_wunlock( Entry *e );
|
||||
int entry_rdwr_init( Entry *e );
|
||||
|
||||
/*
|
||||
* filter.c
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -221,8 +221,7 @@ send_search_entry(
|
|||
Debug( LDAP_DEBUG_ANY, "ber_alloc failed\n", 0, 0, 0 );
|
||||
send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR, NULL,
|
||||
"ber_alloc" );
|
||||
free(edn);
|
||||
return( 1 );
|
||||
goto error_return;
|
||||
}
|
||||
|
||||
#ifdef COMPAT30
|
||||
|
|
@ -241,8 +240,7 @@ send_search_entry(
|
|||
ber_free( ber, 1 );
|
||||
send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR, NULL,
|
||||
"ber_printf dn" );
|
||||
free(edn);
|
||||
return( 1 );
|
||||
goto error_return;
|
||||
}
|
||||
|
||||
for ( a = e->e_attrs; a != NULL; a = a->a_next ) {
|
||||
|
|
@ -277,8 +275,7 @@ send_search_entry(
|
|||
ber_free( ber, 1 );
|
||||
send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR,
|
||||
NULL, "ber_printf type" );
|
||||
free(edn);
|
||||
return( 1 );
|
||||
goto error_return;
|
||||
}
|
||||
|
||||
if ( ! attrsonly ) {
|
||||
|
|
@ -300,8 +297,7 @@ send_search_entry(
|
|||
send_ldap_result( conn, op,
|
||||
LDAP_OPERATIONS_ERROR, NULL,
|
||||
"ber_printf value" );
|
||||
free(edn);
|
||||
return( 1 );
|
||||
goto error_return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -311,8 +307,7 @@ send_search_entry(
|
|||
ber_free( ber, 1 );
|
||||
send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR,
|
||||
NULL, "ber_printf type end" );
|
||||
free(edn);
|
||||
return( 1 );
|
||||
goto error_return;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -390,6 +385,10 @@ send_search_entry(
|
|||
Debug( LDAP_DEBUG_TRACE, "<= send_search_entry\n", 0, 0, 0 );
|
||||
|
||||
return( rc );
|
||||
|
||||
error_return:;
|
||||
free(edn);
|
||||
return( 1 );
|
||||
}
|
||||
|
||||
int
|
||||
|
|
|
|||
|
|
@ -8,11 +8,14 @@
|
|||
#include <syslog.h>
|
||||
#include <sys/types.h>
|
||||
#include <regex.h>
|
||||
#undef NDEBUG
|
||||
#include <assert.h>
|
||||
|
||||
#include "avl.h"
|
||||
#include "lber.h"
|
||||
#include "ldap.h"
|
||||
#include "lthread.h"
|
||||
#include "lthread_rdwr.h"
|
||||
#include "ldif.h"
|
||||
|
||||
#define DN_DNS 0
|
||||
|
|
@ -109,6 +112,9 @@ typedef struct entry {
|
|||
ID e_id; /* id of this entry - this should */
|
||||
/* really be private to back-ldbm */
|
||||
char e_state; /* for the cache */
|
||||
|
||||
pthread_rdwr_t e_rdwr; /* reader/writer lock */
|
||||
|
||||
#define ENTRY_STATE_DELETED 1
|
||||
#define ENTRY_STATE_CREATING 2
|
||||
int e_refcnt; /* # threads ref'ing this entry */
|
||||
|
|
|
|||
Loading…
Reference in a new issue