#include "back-bdb.h"
#include "external.h"
+static char bdb_gid[DB_XIDDATASIZE];
+
int
bdb_add(
BackendDB *be,
if( 0 ) {
retry: /* transaction retry */
- rc = txn_abort( ltid );
+ rc = TXN_ABORT( ltid );
ltid = NULL;
op->o_private = NULL;
if( rc != 0 ) {
}
/* begin transaction */
- rc = txn_begin( bdb->bi_dbenv, NULL, <id,
+ rc = TXN_BEGIN( bdb->bi_dbenv, NULL, <id,
bdb->bi_db_opflags );
text = NULL;
if( rc != 0 ) {
}
if( op->o_noop ) {
- rc = txn_abort( ltid );
+ if (( rc=TXN_ABORT( ltid )) != 0 ) {
+ text = "txn_abort (no-op) failed";
+ } else {
+ rc = LDAP_SUCCESS;
+ }
+
} else {
- rc = txn_commit( ltid, 0 );
+ if (( rc=TXN_PREPARE( ltid, bdb_gid )) != 0 ) {
+ text = "txn_prepare failed";
+
+ } else {
+ if ( bdb_cache_add_entry_rw(&bdb->bi_cache,
+ e, CACHE_WRITE_LOCK) != 0 )
+ {
+ if(( rc=TXN_ABORT( ltid )) != 0 ) {
+ text = "cache add & txn_abort failed";
+ } else {
+ rc = LDAP_OTHER;
+ text = "cache add failed";
+ }
+ } else {
+ if(( rc=TXN_COMMIT( ltid, 0 )) != 0 ) {
+ text = "txn_commit failed";
+ } else {
+ rc = LDAP_SUCCESS;
+ }
+ }
+ }
}
+
ltid = NULL;
op->o_private = NULL;
- if( rc != 0 ) {
- Debug( LDAP_DEBUG_TRACE,
- "bdb_add: txn_%s failed: %s (%d)\n",
- op->o_noop ? "abort (no-op)" : "commit",
- db_strerror(rc), rc );
- rc = LDAP_OTHER;
- text = "commit failed";
-
- } else {
- /* add the entry to the entry cache */
- /* we should add to cache only upon free of txn-abort */
- if (!op->o_noop &&
- bdb_cache_add_entry_rw(&bdb->bi_cache, e, CACHE_WRITE_LOCK) != 0)
- {
- text = "cache add failed";
- goto return_results;
- }
-
- Debug( LDAP_DEBUG_TRACE,
- "bdb_add: added%s id=%08lx dn=\"%s\"\n",
- op->o_noop ? " (no-op)" : "",
- e->e_id, e->e_dn );
- rc = LDAP_SUCCESS;
+ if (rc == LDAP_SUCCESS) {
+ Debug(LDAP_DEBUG_TRACE, "bdb_add: added%s id=%08lx dn=\"%s\"\n",
+ op->o_noop ? " (no-op)" : "", e->e_id, e->e_dn );
text = NULL;
+ bdb_cache_entry_commit( e );
+ }
+ else {
+ Debug( LDAP_DEBUG_TRACE, "bdb_add: %s : %s (%d)\n",
+ text, db_strerror(rc), rc );
+ rc = LDAP_OTHER;
}
-
- bdb_cache_entry_commit( e );
return_results:
send_ldap_result( conn, op, rc,
done:
if( ltid != NULL ) {
- txn_abort( ltid );
+ TXN_ABORT( ltid );
op->o_private = NULL;
}
};
#if DB_VERSION_MAJOR < 4
-#define TXN_CHECKPOINT(env, k, m, f) txn_checkpoint(env, k, m, f)
-#define TXN_ID(txn) txn_id(txn)
-#define LOCK_DETECT(env, f, t, a) lock_detect(env, f, t, a)
-#define LOCK_GET(env, i, f, o, m, l) lock_get(env, i, f, o, m, l)
+#define LOCK_DETECT(env,f,t,a) lock_detect(env, f, t, a)
+#define LOCK_GET(env,i,f,o,m,l) lock_get(env, i, f, o, m, l)
+#define TXN_CHECKPOINT(env,k,m,f) txn_checkpoint(env, k, m, f)
+#define TXN_BEGIN(env,p,t,f) txn_begin((env), p, t, f)
+#define TXN_PREPARE(txn,gid) txn_prepare((txn), (gid))
+#define TXN_COMMIT(txn,f) txn_commit((txn), (f))
+#define TXN_ABORT(txn) txn_abort((txn))
+#define TXN_ID(txn) txn_id(txn)
#else
-#define TXN_CHECKPOINT(env, k, m, f) (env)->txn_checkpoint(env, k, m, f)
-#define TXN_ID(txn) (txn)->id(txn)
-#define LOCK_DETECT(env, f, t, a) (env)->lock_detect(env, f, t, a)
-#define LOCK_GET(env, i, f, o, m, l) (env)->lock_get(env, i, f, o, m, l)
+#define LOCK_DETECT(env,f,t,a) (env)->lock_detect(env, f, t, a)
+#define LOCK_GET(env,i,f,o,m,l) (env)->lock_get(env, i, f, o, m, l)
+#define TXN_CHECKPOINT(env,k,m,f) (env)->txn_checkpoint(env, k, m, f)
+#define TXN_BEGIN(env,p,t,f) (env)->txn_begin((env), p, t, f)
+#define TXN_PREPARE(txn,g) (txn)->prepare((txn), (g))
+#define TXN_COMMIT(txn,f) (txn)->commit((txn), (f))
+#define TXN_ABORT(txn) (txn)->abort((txn))
+#define TXN_ID(txn) (txn)->id(txn)
#endif
LDAP_END_DECL
}
Debug( LDAP_DEBUG_TRACE, "==> bdb_delete: retrying...\n",
0, 0, 0 );
- rc = txn_abort( ltid );
+ rc = TXN_ABORT( ltid );
ltid = NULL;
op->o_private = NULL;
if( rc != 0 ) {
}
/* begin transaction */
- rc = txn_begin( bdb->bi_dbenv, NULL, <id,
+ rc = TXN_BEGIN( bdb->bi_dbenv, NULL, <id,
bdb->bi_db_opflags );
text = NULL;
if( rc != 0 ) {
#endif
if( op->o_noop ) {
- rc = txn_abort( ltid );
+ rc = TXN_ABORT( ltid );
} else {
- rc = txn_commit( ltid, 0 );
+ rc = TXN_COMMIT( ltid, 0 );
}
ltid = NULL;
op->o_private = NULL;
}
if( ltid != NULL ) {
- txn_abort( ltid );
+ TXN_ABORT( ltid );
op->o_private = NULL;
}
}
Debug(LDAP_DEBUG_TRACE,
"bdb_modify: retrying...\n", 0, 0, 0);
- rc = txn_abort( ltid );
+ rc = TXN_ABORT( ltid );
ltid = NULL;
op->o_private = NULL;
if( rc != 0 ) {
}
/* begin transaction */
- rc = txn_begin( bdb->bi_dbenv, NULL, <id,
+ rc = TXN_BEGIN( bdb->bi_dbenv, NULL, <id,
bdb->bi_db_opflags );
text = NULL;
if( rc != 0 ) {
}
if( op->o_noop ) {
- rc = txn_abort( ltid );
+ rc = TXN_ABORT( ltid );
} else {
- rc = txn_commit( ltid, 0 );
+ rc = TXN_COMMIT( ltid, 0 );
}
ltid = NULL;
op->o_private = NULL;
done:
if( ltid != NULL ) {
- txn_abort( ltid );
+ TXN_ABORT( ltid );
op->o_private = NULL;
}
#include "back-bdb.h"
#include "external.h"
+static char bdb_gid[DB_XIDDATASIZE];
+
int
bdb_modrdn(
- Backend *be,
- Connection *conn,
- Operation *op,
- struct berval *dn,
- struct berval *ndn,
- struct berval *newrdn,
- struct berval *nnewrdn,
- int deleteoldrdn,
- struct berval *newSuperior,
- struct berval *nnewSuperior
-)
+ Backend *be,
+ Connection *conn,
+ Operation *op,
+ struct berval *dn,
+ struct berval *ndn,
+ struct berval *newrdn,
+ struct berval *nnewrdn,
+ int deleteoldrdn,
+ struct berval *newSuperior,
+ struct berval *nnewSuperior )
{
struct bdb_info *bdb = (struct bdb_info *) be->be_private;
AttributeDescription *children = slap_schema.si_ad_children;
bdb_cache_return_entry_r(&bdb->bi_cache, np);
}
Debug( LDAP_DEBUG_TRACE, "==>bdb_modrdn: retrying...\n", 0, 0, 0 );
- rc = txn_abort( ltid );
+ rc = TXN_ABORT( ltid );
ltid = NULL;
op->o_private = NULL;
if( rc != 0 ) {
}
/* begin transaction */
- rc = txn_begin( bdb->bi_dbenv, NULL, <id,
+ rc = TXN_BEGIN( bdb->bi_dbenv, NULL, <id,
bdb->bi_db_opflags );
text = NULL;
if( rc != 0 ) {
e->e_nname = new_ndn;
new_dn.bv_val = NULL;
- new_ndn.bv_val = NULL;
+ new_ndn.bv_val = NULL;
/* add new one */
rc = bdb_dn2id_add( be, ltid, np_ndn, e );
}
if( op->o_noop ) {
- rc = txn_abort( ltid );
+ if(( rc=TXN_ABORT( ltid )) != 0 ) {
+ text = "txn_abort (no-op) failed";
+ } else {
+ rc = LDAP_SUCCESS;
+ }
+
} else {
- rc = txn_commit( ltid, 0 );
+ if(( rc=TXN_PREPARE( ltid, bdb_gid )) != 0 ) {
+ text = "txn_prepare failed";
+ } else {
+ if( bdb_cache_update_entry(&bdb->bi_cache, e) == -1 ) {
+ if(( rc=TXN_ABORT( ltid )) != 0 ) {
+ text ="cache update & txn_abort failed";
+ } else {
+ rc = LDAP_OTHER;
+ text = "cache update failed";
+ }
+
+ } else {
+ if(( rc=TXN_COMMIT( ltid, 0 )) != 0 ) {
+ text = "txn_commit failed";
+ } else {
+ rc = LDAP_SUCCESS;
+ }
+ }
+ }
}
+
ltid = NULL;
op->o_private = NULL;
-
- if( rc != 0 ) {
- Debug( LDAP_DEBUG_TRACE,
- "bdb_modrdn: txn_%s failed: %s (%d)\n",
- op->o_noop ? "abort (no-op)" : "commit",
- db_strerror(rc), rc );
- rc = LDAP_OTHER;
- text = "commit failed";
-
- } else {
- (void) bdb_cache_update_entry(&bdb->bi_cache, e);
- Debug( LDAP_DEBUG_TRACE,
- "bdb_modrdn: added%s id=%08lx dn=\"%s\"\n",
- op->o_noop ? " (no-op)" : "",
- e->e_id, e->e_dn );
- rc = LDAP_SUCCESS;
+
+ if( rc == LDAP_SUCCESS ) {
+ Debug(LDAP_DEBUG_TRACE,
+ "bdb_modrdn: rdn modified%s id=%08lx dn=\"%s\"\n",
+ op->o_noop ? " (no-op)" : "", e->e_id, e->e_dn );
text = NULL;
bdb_cache_entry_commit( e );
+
+ } else {
+ Debug( LDAP_DEBUG_TRACE, "bdb_add: %s : %s (%d)\n",
+ text, db_strerror(rc), rc );
+ rc = LDAP_OTHER;
}
return_results:
}
if( ltid != NULL ) {
- txn_abort( ltid );
+ TXN_ABORT( ltid );
op->o_private = NULL;
}
bdb_cache_return_entry_w(&bdb->bi_cache, e);
}
Debug( LDAP_DEBUG_TRACE, "bdb_exop_passwd: retrying...\n", 0, 0, 0 );
- rc = txn_abort( ltid );
+ rc = TXN_ABORT( ltid );
ltid = NULL;
op->o_private = NULL;
if( rc != 0 ) {
}
/* begin transaction */
- rc = txn_begin( bdb->bi_dbenv, NULL, <id,
+ rc = TXN_BEGIN( bdb->bi_dbenv, NULL, <id,
bdb->bi_db_opflags );
*text = NULL;
if( rc != 0 ) {
if( rc == 0 ) {
if( op->o_noop ) {
- rc = txn_abort( ltid );
+ rc = TXN_ABORT( ltid );
} else {
- rc = txn_commit( ltid, 0 );
+ rc = TXN_COMMIT( ltid, 0 );
}
ltid = NULL;
}
}
if( ltid != NULL ) {
- txn_abort( ltid );
+ TXN_ABORT( ltid );
op->o_private = NULL;
}
Debug( LDAP_DEBUG_TRACE, "=> bdb_tool_entry_put( %ld, \"%s\" )\n",
(long) e->e_id, e->e_dn, 0 );
- rc = txn_begin( bdb->bi_dbenv, NULL, &tid,
+ rc = TXN_BEGIN( bdb->bi_dbenv, NULL, &tid,
bdb->bi_db_opflags );
if( rc != 0 ) {
snprintf( text->bv_val, text->bv_len,
done:
if( rc == 0 ) {
- rc = txn_commit( tid, 0 );
+ rc = TXN_COMMIT( tid, 0 );
if( rc != 0 ) {
snprintf( text->bv_val, text->bv_len,
"txn_commit failed: %s (%d)",
}
} else {
- txn_abort( tid );
+ TXN_ABORT( tid );
snprintf( text->bv_val, text->bv_len,
"txn_aborted! %s (%d)",
db_strerror(rc), rc );
return -1;
}
- rc = txn_begin( bi->bi_dbenv, NULL, &tid, bi->bi_db_opflags );
+ rc = TXN_BEGIN( bi->bi_dbenv, NULL, &tid, bi->bi_db_opflags );
if( rc != 0 ) {
Debug( LDAP_DEBUG_ANY,
"=> bdb_tool_entry_reindex: txn_begin failed: %s (%d)\n",
done:
if( rc == 0 ) {
- rc = txn_commit( tid, 0 );
+ rc = TXN_COMMIT( tid, 0 );
if( rc != 0 ) {
Debug( LDAP_DEBUG_ANY,
"=> bdb_tool_entry_reindex: txn_commit failed: %s (%d)\n",
}
} else {
- txn_abort( tid );
+ TXN_ABORT( tid );
Debug( LDAP_DEBUG_ANY,
"=> bdb_tool_entry_reindex: txn_aborted! %s (%d)\n",
db_strerror(rc), rc, 0 );