]> git.sur5r.net Git - openldap/blob - servers/slapd/back-bdb/operational.c
Delete extranous assert()
[openldap] / servers / slapd / back-bdb / operational.c
1 /* operational.c - bdb backend operational attributes function */
2 /*
3  * Copyright 1998-2002 The OpenLDAP Foundation, All Rights Reserved.
4  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
5  */
6
7 #include "portable.h"
8
9 #include <stdio.h>
10
11 #include <ac/string.h>
12 #include <ac/socket.h>
13
14 #include "slap.h"
15 #include "back-bdb.h"
16 #include "proto-bdb.h"
17
18 /*
19  * sets the supported operational attributes (if required)
20  */
21
22 int
23 bdb_operational(
24         BackendDB       *be,
25         Connection      *conn, 
26         Operation       *op,
27         Entry           *e,
28         AttributeName           *attrs,
29         int             opattrs,
30         Attribute       **a )
31 {
32         struct bdb_info *bdb = (struct bdb_info *) be->be_private;
33         Attribute       **aa = a;
34         int             rc;
35         DB_TXN          *ltid = NULL;
36         struct bdb_op_info opinfo;
37         
38         assert( e );
39
40         if ( !opattrs && !ad_inlist( slap_schema.si_ad_hasSubordinates, attrs ) ) {
41                 return 0;
42         }
43
44
45         if( 0 ) {
46 retry:  /* transaction retry */
47                 if( e != NULL ) {
48                         bdb_cache_return_entry_w(&bdb->bi_cache, e);
49                 }
50 #ifdef NEW_LOGGING
51                 LDAP_LOG (( "operational", LDAP_LEVEL_DETAIL1,
52                         "=> bdb_operational: retrying...\n" ));
53 #else
54                 Debug( LDAP_DEBUG_TRACE, "==> bdb_operational: retrying...\n", 
55                                 0, 0, 0 );
56 #endif
57                 rc = TXN_ABORT( ltid );
58                 ltid = NULL;
59                 op->o_private = NULL;
60                 if( rc != 0 ) {
61                         rc = LDAP_OTHER;
62                         goto return_results;
63                 }
64                 ldap_pvt_thread_yield();
65         }
66
67         /* begin transaction */
68         rc = TXN_BEGIN( bdb->bi_dbenv, NULL, &ltid, bdb->bi_db_opflags );
69         if ( rc != 0 ) {
70 #ifdef NEW_LOGGING
71                 LDAP_LOG (( "operational", LDAP_LEVEL_ERR,
72                         "=> bdb_operational: txn_begin failed: %s (%d)\n",
73                          db_strerror(rc), rc ));
74 #else
75                 Debug( LDAP_DEBUG_TRACE,
76                         "bdb_operational: txn_begin failed: %s (%d)\n",
77                         db_strerror( rc ), rc, 0 );
78 #endif
79                 rc = LDAP_OTHER;
80                 return rc;
81         }
82
83         opinfo.boi_bdb = be;
84         opinfo.boi_txn = ltid;
85         opinfo.boi_err = 0;
86         op->o_private = &opinfo;
87
88         rc = bdb_dn2id_children( be, ltid, &e->e_nname );
89         
90         switch( rc ) {
91         case DB_LOCK_DEADLOCK:
92         case DB_LOCK_NOTGRANTED:
93                 goto retry;
94
95         case 0:
96         case DB_NOTFOUND:
97                 *aa = slap_operational_hasSubordinate( rc == 0 );
98                 if ( *aa != NULL ) {
99                         aa = &(*aa)->a_next;
100                 }
101                 break;
102
103         default:
104 #ifdef NEW_LOGGING
105                 LDAP_LOG (( "operational", LDAP_LEVEL_ERR,
106                         "=> bdb_operational: has_children failed: %s (%d)\n",
107                          db_strerror(rc), rc ));
108 #else
109                 Debug(LDAP_DEBUG_ARGS, 
110                         "<=- bdb_operational: has_children failed: %s (%d)\n", 
111                         db_strerror(rc), rc, 0 );
112 #endif
113                 rc = LDAP_OTHER;
114         }
115
116 return_results:
117         if ( rc == LDAP_SUCCESS && bdb->bi_txn_cp ) {
118                 ldap_pvt_thread_yield();
119                 TXN_CHECKPOINT( bdb->bi_dbenv,
120                         bdb->bi_txn_cp_kbyte, bdb->bi_txn_cp_min, 0 );
121         }
122
123         if ( ltid != NULL ) {
124                 TXN_ABORT( ltid );
125                 op->o_private = NULL;
126         }
127
128         return rc;
129 }
130