1 /* entry.c - ldbm backend entry_release routine */
3 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
5 * Copyright 1998-2005 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)";
80 Debug( LDAP_DEBUG_ARGS,
81 "=> ldbm_back_entry_get: ndn: \"%s\"\n", ndn->bv_val, 0, 0 );
82 Debug( LDAP_DEBUG_ARGS,
83 "=> ldbm_back_entry_get: oc: \"%s\", at: \"%s\"\n",
84 oc ? oc->soc_cname.bv_val : "(null)", at_name, 0);
86 /* don't grab the giant lock - our caller has already gotten it. */
88 /* can we find entry */
89 e = dn2entry_rw( op->o_bd, ndn, NULL, rw );
91 Debug( LDAP_DEBUG_ACL,
92 "=> ldbm_back_entry_get: cannot find entry: \"%s\"\n",
94 return LDAP_NO_SUCH_OBJECT;
97 Debug( LDAP_DEBUG_ACL,
98 "=> ldbm_back_entry_get: found entry: \"%s\"\n",
102 /* find attribute values */
103 if( is_entry_alias( e ) ) {
104 Debug( LDAP_DEBUG_ACL,
105 "<= ldbm_back_entry_get: entry is an alias\n", 0, 0, 0 );
106 rc = LDAP_ALIAS_PROBLEM;
111 if( is_entry_referral( e ) ) {
112 Debug( LDAP_DEBUG_ACL,
113 "<= ldbm_back_entry_get: entry is a referral\n", 0, 0, 0 );
118 if ( oc && !is_entry_objectclass( e, oc, 0 )) {
119 Debug( LDAP_DEBUG_ACL,
120 "<= ldbm_back_entry_get: failed to find objectClass %s\n",
121 oc->soc_cname.bv_val, 0, 0 );
122 rc = LDAP_NO_SUCH_ATTRIBUTE;
129 if( rc != LDAP_SUCCESS ) {
131 cache_return_entry_rw(&li->li_cache, e, rw);
136 Debug( LDAP_DEBUG_TRACE,
137 "ldbm_back_entry_get: rc=%d\n",