1 /* operational.c - bdb backend operational attributes function */
3 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
5 * Copyright 2000-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/string.h>
22 #include <ac/socket.h>
28 * sets *hasSubordinates to LDAP_COMPARE_TRUE/LDAP_COMPARE_FALSE
29 * if the entry has children or not.
35 int *hasSubordinates )
41 /* NOTE: this should never happen, but it actually happens
42 * when using back-relay; until we find a better way to
43 * preserve entry's private information while rewriting it,
44 * let's disable the hasSubordinate feature for back-relay.
46 if ( BEI( e ) == NULL ) {
51 /* FIXME: we can no longer assume the entry's e_private
52 * field is correctly populated; so we need to reacquire
53 * it with reader lock */
54 rc = bdb_cache_children( op, NULL, e );
57 case DB_LOCK_DEADLOCK:
58 case DB_LOCK_NOTGRANTED:
59 ldap_pvt_thread_yield();
63 *hasSubordinates = LDAP_COMPARE_TRUE;
67 *hasSubordinates = LDAP_COMPARE_FALSE;
72 Debug(LDAP_DEBUG_ARGS,
73 "<=- " LDAP_XSTRING(bdb_hasSubordinates)
74 ": has_children failed: %s (%d)\n",
75 db_strerror(rc), rc, 0 );
83 * sets the supported operational attributes (if required)
92 assert( rs->sr_entry );
94 for ( ap = &rs->sr_operational_attrs; *ap; ap = &(*ap)->a_next )
97 if ( SLAP_OPATTRS( rs->sr_attr_flags ) ||
98 ad_inlist( slap_schema.si_ad_hasSubordinates, rs->sr_attrs ) )
100 int hasSubordinates, rc;
102 rc = bdb_hasSubordinates( op, rs->sr_entry, &hasSubordinates );
103 if ( rc == LDAP_SUCCESS ) {
104 *ap = slap_operational_hasSubordinate( hasSubordinates == LDAP_COMPARE_TRUE );