From 4f0e4f60bd1378f0b898477208311611f95e8f40 Mon Sep 17 00:00:00 2001 From: Kurt Zeilenga Date: Tue, 29 Jan 2002 00:02:27 +0000 Subject: [PATCH] Add first cut BDB no-op control support. --- servers/slapd/back-bdb/add.c | 32 +++++++++++++++++++------------ servers/slapd/back-bdb/delete.c | 16 +++++++++++----- servers/slapd/back-bdb/id2entry.c | 3 ++- servers/slapd/back-bdb/init.c | 2 -- servers/slapd/back-bdb/modify.c | 14 ++++++++++---- servers/slapd/back-bdb/modrdn.c | 17 +++++++++++----- servers/slapd/back-bdb/passwd.c | 6 +++++- 7 files changed, 60 insertions(+), 30 deletions(-) diff --git a/servers/slapd/back-bdb/add.c b/servers/slapd/back-bdb/add.c index 6d03e22db0..961aa0a8ed 100644 --- a/servers/slapd/back-bdb/add.c +++ b/servers/slapd/back-bdb/add.c @@ -339,33 +339,41 @@ retry: /* transaction retry */ goto return_results; } - rc = txn_commit( ltid, 0 ); + if( op->o_noop ) { + rc = txn_abort( ltid ); + } else { + rc = txn_commit( ltid, 0 ); + } ltid = NULL; op->o_private = NULL; if( rc != 0 ) { Debug( LDAP_DEBUG_TRACE, - "bdb_add: txn_commit failed: %s (%d)\n", - db_strerror(rc), rc, 0 ); + "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 (bdb_cache_add_entry_rw(&bdb->bi_cache, e, CACHE_WRITE_LOCK) != 0) { - text = "cache add failed"; - goto return_results; - } + /* 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 id=%08lx dn=\"%s\"\n", - e->e_id, e->e_dn, 0 ); + "bdb_add: added%s id=%08lx dn=\"%s\"\n", + op->o_noop ? " (no-op)" : "", + e->e_id, e->e_dn ); rc = LDAP_SUCCESS; text = NULL; } - bdb_cache_entry_commit (e); + bdb_cache_entry_commit( e ); return_results: send_ldap_result( conn, op, rc, diff --git a/servers/slapd/back-bdb/delete.c b/servers/slapd/back-bdb/delete.c index b79cf104df..f09b2963b1 100644 --- a/servers/slapd/back-bdb/delete.c +++ b/servers/slapd/back-bdb/delete.c @@ -332,21 +332,27 @@ retry: /* transaction retry */ ldap_pvt_thread_mutex_unlock( &bdb->bi_lastid_mutex ); #endif - rc = txn_commit( ltid, 0 ); + if( op->o_noop ) { + rc = txn_abort( ltid ); + } else { + rc = txn_commit( ltid, 0 ); + } ltid = NULL; op->o_private = NULL; if( rc != 0 ) { Debug( LDAP_DEBUG_TRACE, - "bdb_delete: txn_commit failed: %s (%d)\n", - db_strerror(rc), rc, 0 ); + "bdb_delete: txn_%s failed: %s (%d)\n", + op->o_noop ? "abort (no-op)" : "commit", + db_strerror(rc), rc ); rc = LDAP_OTHER; text = "commit failed"; } else { Debug( LDAP_DEBUG_TRACE, - "bdb_delete: deleted id=%08lx dn=\"%s\"\n", - e->e_id, e->e_dn, 0 ); + "bdb_delete: deleted%s id=%08lx dn=\"%s\"\n", + op->o_noop ? " (no-op)" : "", + e->e_id, e->e_dn ); rc = LDAP_SUCCESS; text = NULL; } diff --git a/servers/slapd/back-bdb/id2entry.c b/servers/slapd/back-bdb/id2entry.c index c67359c339..037183b547 100644 --- a/servers/slapd/back-bdb/id2entry.c +++ b/servers/slapd/back-bdb/id2entry.c @@ -135,8 +135,9 @@ int bdb_id2entry_rw( bdb_fix_dn(be, id, *e); #endif - if (rc == 0) + if (rc == 0) { bdb_cache_entry_commit(*e); + } return rc; } diff --git a/servers/slapd/back-bdb/init.c b/servers/slapd/back-bdb/init.c index c61a1618d9..b51ca852b9 100644 --- a/servers/slapd/back-bdb/init.c +++ b/servers/slapd/back-bdb/init.c @@ -401,9 +401,7 @@ bdb_initialize( static char *controls[] = { LDAP_CONTROL_MANAGEDSAIT, LDAP_CONTROL_SUBENTRIES, -#if 0 LDAP_CONTROL_NOOP, -#endif NULL }; diff --git a/servers/slapd/back-bdb/modify.c b/servers/slapd/back-bdb/modify.c index 44002bf325..f21eba17d9 100644 --- a/servers/slapd/back-bdb/modify.c +++ b/servers/slapd/back-bdb/modify.c @@ -328,20 +328,26 @@ retry: /* transaction retry */ goto return_results; } - rc = txn_commit( ltid, 0 ); + if( op->o_noop ) { + rc = txn_abort( ltid ); + } else { + rc = txn_commit( ltid, 0 ); + } ltid = NULL; op->o_private = NULL; if( rc != 0 ) { Debug( LDAP_DEBUG_TRACE, - "bdb_modify: txn_commit failed: %s (%d)\n", - db_strerror(rc), rc, 0 ); + "bdb_modify: txn_%s failed: %s (%d)\n", + op->o_noop ? "abort (no-op)" : "commit", + db_strerror(rc), rc ); rc = LDAP_OTHER; text = "commit failed"; } else { Debug( LDAP_DEBUG_TRACE, - "bdb_modify: updated id=%08lx dn=\"%s\"\n", + "bdb_modify: updated%s id=%08lx dn=\"%s\"\n", + op->o_noop ? " (no-op)" : "", e->e_id, e->e_dn, 0 ); rc = LDAP_SUCCESS; text = NULL; diff --git a/servers/slapd/back-bdb/modrdn.c b/servers/slapd/back-bdb/modrdn.c index 5e9e4776a4..73c7d21252 100644 --- a/servers/slapd/back-bdb/modrdn.c +++ b/servers/slapd/back-bdb/modrdn.c @@ -620,21 +620,28 @@ retry: /* transaction retry */ goto return_results; } - rc = txn_commit( ltid, 0 ); + if( op->o_noop ) { + rc = txn_abort( ltid ); + } else { + rc = txn_commit( ltid, 0 ); + } ltid = NULL; op->o_private = NULL; if( rc != 0 ) { Debug( LDAP_DEBUG_TRACE, - "bdb_modrdn: txn_commit failed: %s (%d)\n", - db_strerror(rc), rc, 0 ); + "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 id=%08lx dn=\"%s\"\n", - e->e_id, e->e_dn, 0 ); + "bdb_modrdn: added%s id=%08lx dn=\"%s\"\n", + op->o_noop ? " (no-op)" : "", + e->e_id, e->e_dn ); rc = LDAP_SUCCESS; text = NULL; bdb_cache_entry_commit( e ); diff --git a/servers/slapd/back-bdb/passwd.c b/servers/slapd/back-bdb/passwd.c index cbad790f1c..003f85691a 100644 --- a/servers/slapd/back-bdb/passwd.c +++ b/servers/slapd/back-bdb/passwd.c @@ -198,7 +198,11 @@ retry: /* transaction retry */ } if( rc == 0 ) { - rc = txn_commit( ltid, 0 ); + if( op->o_noop ) { + rc = txn_abort( ltid ); + } else { + rc = txn_commit( ltid, 0 ); + } ltid = NULL; } op->o_private = NULL; -- 2.39.5