1 /* entry.c - ldbm backend entry_release routine */
4 * Copyright 1998-2003 The OpenLDAP Foundation, All Rights Reserved.
5 * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
12 #include <ac/socket.h>
13 #include <ac/string.h>
16 #include "back-ldbm.h"
17 #include "proto-back-ldbm.h"
21 ldbm_back_entry_release_rw(
27 struct ldbminfo *li = (struct ldbminfo *) op->o_bd->be_private;
29 if ( slapMode == SLAP_SERVER_MODE ) {
30 /* free entry and reader or writer lock */
31 cache_return_entry_rw( &li->li_cache, e, rw );
32 /* only do_add calls here with a write lock.
33 * get_entry doesn't obtain the giant lock, because its
34 * caller has already obtained it.
37 ldap_pvt_thread_rdwr_wunlock( &li->li_giant_rwlock );
41 ldap_pvt_thread_rdwr_runlock( &li->li_giant_rwlock );
52 /* return LDAP_SUCCESS IFF we can retrieve the specified entry.
54 int ldbm_back_entry_get(
58 AttributeDescription *at,
62 struct ldbminfo *li = (struct ldbminfo *) op->o_bd->be_private;
65 const char *at_name = at->ad_cname.bv_val;
68 LDAP_LOG( BACK_BDB, ARGS,
69 "ldbm_back_entry_get: ndn: \"%s\"\n", ndn->bv_val, 0, 0 );
70 LDAP_LOG( BACK_BDB, ARGS,
71 "ldbm_back_entry_get: oc: \"%s\", at: \"%s\"\n",
72 oc ? oc->soc_cname.bv_val : "(null)", at_name, 0);
74 Debug( LDAP_DEBUG_ARGS,
75 "=> ldbm_back_entry_get: ndn: \"%s\"\n", ndn->bv_val, 0, 0 );
76 Debug( LDAP_DEBUG_ARGS,
77 "=> ldbm_back_entry_get: oc: \"%s\", at: \"%s\"\n",
78 oc ? oc->soc_cname.bv_val : "(null)", at_name, 0);
81 /* don't grab the giant lock - our caller has already gotten it. */
83 /* can we find entry */
84 e = dn2entry_rw( op->o_bd, ndn, NULL, rw );
87 LDAP_LOG( BACK_BDB, INFO,
88 "ldbm_back_entry_get: cannot find entry (%s)\n",
91 Debug( LDAP_DEBUG_ACL,
92 "=> ldbm_back_entry_get: cannot find entry: \"%s\"\n",
95 return LDAP_NO_SUCH_OBJECT;
99 LDAP_LOG( BACK_BDB, DETAIL1, "ldbm_back_entry_get: found entry (%s)\n",
102 Debug( LDAP_DEBUG_ACL,
103 "=> ldbm_back_entry_get: found entry: \"%s\"\n",
108 /* find attribute values */
109 if( is_entry_alias( e ) ) {
111 LDAP_LOG( BACK_BDB, INFO,
112 "ldbm_back_entry_get: entry (%s) is an alias\n", e->e_name.bv_val, 0, 0 );
114 Debug( LDAP_DEBUG_ACL,
115 "<= ldbm_back_entry_get: entry is an alias\n", 0, 0, 0 );
117 rc = LDAP_ALIAS_PROBLEM;
122 if( is_entry_referral( e ) ) {
124 LDAP_LOG( BACK_BDB, INFO,
125 "ldbm_back_entry_get: entry (%s) is a referral.\n", e->e_name.bv_val, 0, 0);
127 Debug( LDAP_DEBUG_ACL,
128 "<= ldbm_back_entry_get: entry is a referral\n", 0, 0, 0 );
134 if ( oc && !is_entry_objectclass( e, oc, 0 )) {
136 LDAP_LOG( BACK_BDB, INFO,
137 "ldbm_back_entry_get: failed to find objectClass.\n", 0, 0, 0 );
139 Debug( LDAP_DEBUG_ACL,
140 "<= ldbm_back_entry_get: failed to find objectClass\n",
143 rc = LDAP_NO_SUCH_ATTRIBUTE;
150 if( rc != LDAP_SUCCESS ) {
152 cache_return_entry_rw(&li->li_cache, e, rw);
158 LDAP_LOG( BACK_BDB, ENTRY, "ldbm_back_entry_get: rc=%d\n", rc, 0, 0 );
160 Debug( LDAP_DEBUG_TRACE,
161 "ldbm_back_entry_get: rc=%d\n",