1 /* entry.c - ldbm backend entry_release routine */
3 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
5 * Copyright 1998-2004 The OpenLDAP Foundation.
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted only as authorized by the OpenLDAP
12 * A copy of this license is available in the file LICENSE in the
13 * top-level directory of the distribution or, alternatively, at
14 * <http://www.OpenLDAP.org/license.html>.
21 #include <ac/socket.h>
22 #include <ac/string.h>
25 #include "back-ldbm.h"
26 #include "proto-back-ldbm.h"
30 ldbm_back_entry_release_rw(
36 struct ldbminfo *li = (struct ldbminfo *) op->o_bd->be_private;
38 if ( slapMode == SLAP_SERVER_MODE ) {
39 /* free entry and reader or writer lock */
40 cache_return_entry_rw( &li->li_cache, e, rw );
41 /* only do_add calls here with a write lock.
42 * get_entry doesn't obtain the giant lock, because its
43 * caller has already obtained it.
46 ldap_pvt_thread_rdwr_wunlock( &li->li_giant_rwlock );
50 ldap_pvt_thread_rdwr_runlock( &li->li_giant_rwlock );
65 /* return LDAP_SUCCESS IFF we can retrieve the specified entry.
67 int ldbm_back_entry_get(
71 AttributeDescription *at,
75 struct ldbminfo *li = (struct ldbminfo *) op->o_bd->be_private;
78 const char *at_name = at ? at->ad_cname.bv_val : "(null)";
81 LDAP_LOG( BACK_LDBM, ARGS,
82 "ldbm_back_entry_get: ndn: \"%s\"\n", ndn->bv_val, 0, 0 );
83 LDAP_LOG( BACK_LDBM, ARGS,
84 "ldbm_back_entry_get: oc: \"%s\", at: \"%s\"\n",
85 oc ? oc->soc_cname.bv_val : "(null)", at_name, 0);
87 Debug( LDAP_DEBUG_ARGS,
88 "=> ldbm_back_entry_get: ndn: \"%s\"\n", ndn->bv_val, 0, 0 );
89 Debug( LDAP_DEBUG_ARGS,
90 "=> ldbm_back_entry_get: oc: \"%s\", at: \"%s\"\n",
91 oc ? oc->soc_cname.bv_val : "(null)", at_name, 0);
94 /* don't grab the giant lock - our caller has already gotten it. */
96 /* can we find entry */
97 e = dn2entry_rw( op->o_bd, ndn, NULL, rw );
100 LDAP_LOG( BACK_LDBM, INFO,
101 "ldbm_back_entry_get: cannot find entry (%s)\n",
104 Debug( LDAP_DEBUG_ACL,
105 "=> ldbm_back_entry_get: cannot find entry: \"%s\"\n",
108 return LDAP_NO_SUCH_OBJECT;
112 LDAP_LOG( BACK_LDBM, DETAIL1, "ldbm_back_entry_get: found entry (%s)\n",
115 Debug( LDAP_DEBUG_ACL,
116 "=> ldbm_back_entry_get: found entry: \"%s\"\n",
121 /* find attribute values */
122 if( is_entry_alias( e ) ) {
124 LDAP_LOG( BACK_LDBM, INFO,
125 "ldbm_back_entry_get: entry (%s) is an alias\n", e->e_name.bv_val, 0, 0 );
127 Debug( LDAP_DEBUG_ACL,
128 "<= ldbm_back_entry_get: entry is an alias\n", 0, 0, 0 );
130 rc = LDAP_ALIAS_PROBLEM;
135 if( is_entry_referral( e ) ) {
137 LDAP_LOG( BACK_LDBM, INFO,
138 "ldbm_back_entry_get: entry (%s) is a referral.\n", e->e_name.bv_val, 0, 0);
140 Debug( LDAP_DEBUG_ACL,
141 "<= ldbm_back_entry_get: entry is a referral\n", 0, 0, 0 );
147 if ( oc && !is_entry_objectclass( e, oc, 0 )) {
149 LDAP_LOG( BACK_LDBM, INFO,
150 "ldbm_back_entry_get: failed to find objectClass.\n", 0, 0, 0 );
152 Debug( LDAP_DEBUG_ACL,
153 "<= ldbm_back_entry_get: failed to find objectClass\n",
156 rc = LDAP_NO_SUCH_ATTRIBUTE;
163 if( rc != LDAP_SUCCESS ) {
165 cache_return_entry_rw(&li->li_cache, e, rw);
171 LDAP_LOG( BACK_LDBM, ENTRY, "ldbm_back_entry_get: rc=%d\n", rc, 0, 0 );
173 Debug( LDAP_DEBUG_TRACE,
174 "ldbm_back_entry_get: rc=%d\n",