1 /* operational.c - bdb backend operational attributes function */
3 * Copyright 1998-2002 The OpenLDAP Foundation, All Rights Reserved.
4 * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
11 #include <ac/string.h>
12 #include <ac/socket.h>
16 #include "proto-bdb.h"
19 * sets the supported operational attributes (if required)
28 int *hasSubordinates )
30 struct bdb_info *bdb = (struct bdb_info *) be->be_private;
33 struct bdb_op_info opinfo;
36 assert( hasSubordinates );
39 retry: /* transaction retry */
42 bdb_unlocked_cache_return_entry_w(&bdb->bi_cache, e);
46 LDAP_LOG ( OPERATION, DETAIL1,
47 "=> bdb_hasSubordinates: retrying...\n", 0, 0, 0 );
49 Debug( LDAP_DEBUG_TRACE, "==> bdb_hasSubordinates: retrying...\n",
52 rc = TXN_ABORT( ltid );
59 ldap_pvt_thread_yield();
62 /* begin transaction */
63 rc = TXN_BEGIN( bdb->bi_dbenv, NULL, <id, bdb->bi_db_opflags );
66 LDAP_LOG ( OPERATION, ERR,
67 "=> bdb_hasSubordinates: txn_begin failed: %s (%d)\n",
68 db_strerror(rc), rc, 0 );
70 Debug( LDAP_DEBUG_TRACE,
71 "bdb_hasSubordinates: txn_begin failed: %s (%d)\n",
72 db_strerror( rc ), rc, 0 );
79 opinfo.boi_txn = ltid;
81 op->o_private = &opinfo;
83 rc = bdb_dn2id_children( be, ltid, &e->e_nname, 0 );
86 case DB_LOCK_DEADLOCK:
87 case DB_LOCK_NOTGRANTED:
91 *hasSubordinates = LDAP_COMPARE_TRUE;
95 *hasSubordinates = LDAP_COMPARE_FALSE;
101 LDAP_LOG ( OPERATION, ERR,
102 "=> bdb_hasSubordinates: has_children failed: %s (%d)\n",
103 db_strerror(rc), rc, 0 );
105 Debug(LDAP_DEBUG_ARGS,
106 "<=- bdb_hasSubordinates: has_children failed: %s (%d)\n",
107 db_strerror(rc), rc, 0 );
113 if ( rc == LDAP_SUCCESS && bdb->bi_txn_cp ) {
114 ldap_pvt_thread_yield();
115 TXN_CHECKPOINT( bdb->bi_dbenv,
116 bdb->bi_txn_cp_kbyte, bdb->bi_txn_cp_min, 0 );
119 if ( ltid != NULL ) {
121 op->o_private = NULL;
133 AttributeName *attrs,
142 if ( opattrs || ad_inlist( slap_schema.si_ad_hasSubordinates, attrs ) ) {
145 rc = bdb_hasSubordinates( be, conn, op, e, &hasSubordinates );
146 if ( rc == LDAP_SUCCESS ) {
147 *aa = slap_operational_hasSubordinate( hasSubordinates == LDAP_COMPARE_TRUE );