1 /* operational.c - bdb backend operational attributes function */
3 * Copyright 1998-2003 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 *hasSubordinates to LDAP_COMPARE_TRUE/LDAP_COMPARE_FALSE
20 * if the entry has children or not.
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;
80 opinfo.boi_locker = TXN_ID ( ltid );
82 op->o_private = &opinfo;
84 rc = bdb_dn2id_children( be, ltid, &e->e_nname, 0 );
87 case DB_LOCK_DEADLOCK:
88 case DB_LOCK_NOTGRANTED:
92 *hasSubordinates = LDAP_COMPARE_TRUE;
96 *hasSubordinates = LDAP_COMPARE_FALSE;
102 LDAP_LOG ( OPERATION, ERR,
103 "=> bdb_hasSubordinates: has_children failed: %s (%d)\n",
104 db_strerror(rc), rc, 0 );
106 Debug(LDAP_DEBUG_ARGS,
107 "<=- bdb_hasSubordinates: has_children failed: %s (%d)\n",
108 db_strerror(rc), rc, 0 );
114 if ( rc == LDAP_SUCCESS && bdb->bi_txn_cp ) {
115 ldap_pvt_thread_yield();
116 TXN_CHECKPOINT( bdb->bi_dbenv,
117 bdb->bi_txn_cp_kbyte, bdb->bi_txn_cp_min, 0 );
120 if ( ltid != NULL ) {
122 op->o_private = NULL;
129 * sets the supported operational attributes (if required)
137 AttributeName *attrs,
146 if ( opattrs || ad_inlist( slap_schema.si_ad_hasSubordinates, attrs ) ) {
149 rc = bdb_hasSubordinates( be, conn, op, e, &hasSubordinates );
150 if ( rc == LDAP_SUCCESS ) {
151 *aa = slap_operational_hasSubordinate( hasSubordinates == LDAP_COMPARE_TRUE );