From 488862105f8c1c791718d4c53b3958330d369198 Mon Sep 17 00:00:00 2001 From: Kurt Zeilenga Date: Mon, 11 Feb 2002 17:45:39 +0000 Subject: [PATCH] Use UUID to generate a GID for txn_prepare. Based upon submission from Jong Hyuk Choi (ITS#1585 for ITS1575). --- servers/slapd/back-bdb/add.c | 9 ++++++--- servers/slapd/back-bdb/init.c | 12 +++++++++++- servers/slapd/back-bdb/modrdn.c | 9 ++++++--- servers/slapd/back-bdb/proto-bdb.h | 5 +++++ 4 files changed, 28 insertions(+), 7 deletions(-) diff --git a/servers/slapd/back-bdb/add.c b/servers/slapd/back-bdb/add.c index 185bb7ef88..9bc5735859 100644 --- a/servers/slapd/back-bdb/add.c +++ b/servers/slapd/back-bdb/add.c @@ -13,8 +13,6 @@ #include "back-bdb.h" #include "external.h" -static char bdb_gid[DB_XIDDATASIZE]; - int bdb_add( BackendDB *be, @@ -360,7 +358,12 @@ retry: /* transaction retry */ } } else { - if (( rc=TXN_PREPARE( ltid, bdb_gid )) != 0 ) { + char gid[DB_XIDDATASIZE]; + + snprintf( gid, sizeof( gid ), "%s-%08lx-%08lx", + bdb_uuid, (long) op->o_connid, (long) op->o_opid ); + + if (( rc=TXN_PREPARE( ltid, gid )) != 0 ) { text = "txn_prepare failed"; } else { diff --git a/servers/slapd/back-bdb/init.c b/servers/slapd/back-bdb/init.c index 911f23da16..9c6ca5cc58 100644 --- a/servers/slapd/back-bdb/init.c +++ b/servers/slapd/back-bdb/init.c @@ -30,6 +30,8 @@ static struct bdbi_database { { NULL, NULL, 0, 0 } }; +struct berval bdb_uuid = { 0, NULL }; + static int bdb_open( BackendInfo *bi ) { @@ -40,6 +42,8 @@ bdb_open( BackendInfo *bi ) NULL }; + bi->bi_controls = controls; + /* initialize the underlying database system */ Debug( LDAP_DEBUG_TRACE, "bdb_open: initialize BDB backend\n", 0, 0, 0 ); @@ -70,7 +74,13 @@ bdb_open( BackendInfo *bi ) db_env_set_func_yield( ldap_pvt_thread_yield ); - bi->bi_controls = controls; + { + static char uuidbuf[40]; + + bdb_uuid.bv_len = lutil_uuidstr( uuidbuf, sizeof( uuidbuf )); + bdb_uuid.bv_val = uuidbuf; + } + return 0; } diff --git a/servers/slapd/back-bdb/modrdn.c b/servers/slapd/back-bdb/modrdn.c index d6883865c4..64e5ad2e28 100644 --- a/servers/slapd/back-bdb/modrdn.c +++ b/servers/slapd/back-bdb/modrdn.c @@ -13,8 +13,6 @@ #include "back-bdb.h" #include "external.h" -static char bdb_gid[DB_XIDDATASIZE]; - int bdb_modrdn( Backend *be, @@ -631,7 +629,12 @@ retry: /* transaction retry */ } } else { - if(( rc=TXN_PREPARE( ltid, bdb_gid )) != 0 ) { + char gid[DB_XIDDATASIZE]; + + snprintf( gid, sizeof( gid ), "%s-%08lx-%08lx", + bdb_uuid, (long) op->o_connid, (long) op->o_opid ); + + if(( rc=TXN_PREPARE( ltid, gid )) != 0 ) { text = "txn_prepare failed"; } else { if( bdb_cache_update_entry(&bdb->bi_cache, e) == -1 ) { diff --git a/servers/slapd/back-bdb/proto-bdb.h b/servers/slapd/back-bdb/proto-bdb.h index 86d7e1bf5d..d29256860e 100644 --- a/servers/slapd/back-bdb/proto-bdb.h +++ b/servers/slapd/back-bdb/proto-bdb.h @@ -244,6 +244,11 @@ int bdb_index_entry LDAP_P(( Backend *be, DB_TXN *t, #define bdb_index_entry_del(be,t,e,ap) \ bdb_index_entry((be),(t),SLAP_INDEX_DELETE_OP,(e),(ap)) +/* + * init.c + */ +extern struct berval bdb_uuid; + /* * key.c */ -- 2.39.5