From ba701364b9b1dafbb9d2e741728359be3c753a0a Mon Sep 17 00:00:00 2001 From: Rodrigo Pastrana Date: Thu, 8 Feb 2024 19:04:34 -0500 Subject: [PATCH] HPCC-31181 Code Review 3 - Minor code block shift Signed-off-by: Rodrigo Pastrana --- .../ws_store/espstorelib/daliKVStore.cpp | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/esp/services/ws_store/espstorelib/daliKVStore.cpp b/esp/services/ws_store/espstorelib/daliKVStore.cpp index 0db602bab54..b3f1a40419d 100644 --- a/esp/services/ws_store/espstorelib/daliKVStore.cpp +++ b/esp/services/ws_store/espstorelib/daliKVStore.cpp @@ -43,6 +43,15 @@ bool CDALIKVStore::createStore(const char * apptype, const char * storename, con conn.clear(); conn.setown(querySDS().connect(DALI_KVSTORE_PATH, myProcessSession(), RTM_LOCK_WRITE, SDS_LOCK_TIMEOUT_KVSTORE)); + Owned root = conn->getRoot(); + //was the target store created while we were waiting for the lock? + //if so, we don't need to create it again + if (root->hasProp(xpath.str())) + { + LOG(MCuserInfo,"DALI Keystore createStore(): '%s' entry already exists", storename); + return false; + } + Owned apptree = createPTree(); apptree->setProp(DALI_KVSTORE_NAME_ATT, storename); CDateTime dt; @@ -63,13 +72,6 @@ bool CDALIKVStore::createStore(const char * apptype, const char * storename, con if (maxvalsize != 0) apptree->setPropInt(DALI_KVSTORE_MAXVALSIZE_ATT, maxvalsize); - Owned root = conn->getRoot(); - if (root->hasProp(xpath.str())) - { - LOG(MCuserInfo,"DALI Keystore createStore(): '%s' entry already exists", storename); - return false; - } - root->addPropTree("Store", LINK(apptree)); conn->commit();