Loading src/authdb.cpp +20 −1 Changes for src/authdb.cpp: 20 added lines, 1 removed line. Original line number Diff line number Diff line Loading @@ -289,10 +289,12 @@ namespace authdb { return; } DomainInfo dinfo; { AuthBackendLock admlock(_AdminBackend); try { apidb=db.data(did.value); dinfo=db.resolve(did.value); }catch(std::exception &e){ libhttppp::HttpResponse rep; rep.setState(HTTP500); Loading @@ -309,6 +311,23 @@ namespace authdb { } } try { apidb=db.create(dinfo); }catch(std::exception &e){ libhttppp::HttpResponse rep; rep.setState(HTTP500); rep.setContentType("text/html"); rep.send(curreq,e.what(),strlen(e.what())); return; }catch(...){ libhttppp::HttpResponse rep; rep.setState(HTTP500); rep.setContentType("text/html"); char msg[]={"internal error creating domain backend"}; rep.send(curreq,msg,sizeof(msg)); return; } if(apidb){ apidb->lock(); try{ Loading src/authdb.h +14 −0 Changes for src/authdb.h: 14 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -164,10 +164,24 @@ namespace authdb { void vacuumRecords(AuthBackend &backend); struct DomainInfo { int storageType; std::string storageOptions; std::string domainName; bool found = false; }; class DomainBackend { public: DomainBackend(authdb::AuthBackend &adminbck); // Lookup domain metadata only (fast, call under admin lock) DomainInfo resolve(uuid::uuid did); // Create backend from resolved info (slow, call WITHOUT admin lock) authdb::AuthBackend *create(const DomainInfo &info); // Combined: resolve + create (legacy, caller must handle locking) authdb::AuthBackend *data(uuid::uuid did); ~DomainBackend(); Loading src/backends/cluster.cpp +0 −3 Changes for src/backends/cluster.cpp: 0 added lines, 3 removed lines. Original line number Diff line number Diff line Loading @@ -161,9 +161,6 @@ namespace authdb { ClusterBackend::ClusterBackend(const char *domain, size_t version, const char *filepath) : _Domain(domain), _Pos(0), _Dirty(false) { // Give peer servers time to start their event loops std::this_thread::sleep_for(std::chrono::seconds(2)); // Try to fetch existing data from cluster/store fetchFromCluster(); Loading src/domain.cpp +19 −4 Changes for src/domain.cpp: 19 added lines, 4 removed lines. Original line number Diff line number Diff line Loading @@ -177,7 +177,8 @@ namespace authdb { _domainbck=nullptr; } authdb::AuthBackend *DomainBackend::data(::uuid::uuid did){ DomainInfo DomainBackend::resolve(::uuid::uuid did){ DomainInfo info; size_t rd=sizeof(authdb::AuthHeader),end=_adminbck.end(); while(rd<end){ Loading @@ -198,12 +199,26 @@ namespace authdb { Domain domain; domain.info(_adminbck,ddat,dpos); _domainbck = new AuthBackend(ddat.getStorageType(),ddat.getStorageOptions(),ddat.getDomainName()); return _domainbck; info.storageType = ddat.getStorageType(); info.storageOptions = ddat.getStorageOptions(); info.domainName = ddat.getDomainName(); info.found = true; return info; } } return info; } authdb::AuthBackend *DomainBackend::create(const DomainInfo &info){ if(!info.found) return nullptr; _domainbck = new AuthBackend(info.storageType,info.storageOptions,info.domainName); return _domainbck; } authdb::AuthBackend *DomainBackend::data(::uuid::uuid did){ DomainInfo info = resolve(did); return create(info); } DomainBackend::~DomainBackend(){ Loading Loading
src/authdb.cpp +20 −1 Changes for src/authdb.cpp: 20 added lines, 1 removed line. Original line number Diff line number Diff line Loading @@ -289,10 +289,12 @@ namespace authdb { return; } DomainInfo dinfo; { AuthBackendLock admlock(_AdminBackend); try { apidb=db.data(did.value); dinfo=db.resolve(did.value); }catch(std::exception &e){ libhttppp::HttpResponse rep; rep.setState(HTTP500); Loading @@ -309,6 +311,23 @@ namespace authdb { } } try { apidb=db.create(dinfo); }catch(std::exception &e){ libhttppp::HttpResponse rep; rep.setState(HTTP500); rep.setContentType("text/html"); rep.send(curreq,e.what(),strlen(e.what())); return; }catch(...){ libhttppp::HttpResponse rep; rep.setState(HTTP500); rep.setContentType("text/html"); char msg[]={"internal error creating domain backend"}; rep.send(curreq,msg,sizeof(msg)); return; } if(apidb){ apidb->lock(); try{ Loading
src/authdb.h +14 −0 Changes for src/authdb.h: 14 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -164,10 +164,24 @@ namespace authdb { void vacuumRecords(AuthBackend &backend); struct DomainInfo { int storageType; std::string storageOptions; std::string domainName; bool found = false; }; class DomainBackend { public: DomainBackend(authdb::AuthBackend &adminbck); // Lookup domain metadata only (fast, call under admin lock) DomainInfo resolve(uuid::uuid did); // Create backend from resolved info (slow, call WITHOUT admin lock) authdb::AuthBackend *create(const DomainInfo &info); // Combined: resolve + create (legacy, caller must handle locking) authdb::AuthBackend *data(uuid::uuid did); ~DomainBackend(); Loading
src/backends/cluster.cpp +0 −3 Changes for src/backends/cluster.cpp: 0 added lines, 3 removed lines. Original line number Diff line number Diff line Loading @@ -161,9 +161,6 @@ namespace authdb { ClusterBackend::ClusterBackend(const char *domain, size_t version, const char *filepath) : _Domain(domain), _Pos(0), _Dirty(false) { // Give peer servers time to start their event loops std::this_thread::sleep_for(std::chrono::seconds(2)); // Try to fetch existing data from cluster/store fetchFromCluster(); Loading
src/domain.cpp +19 −4 Changes for src/domain.cpp: 19 added lines, 4 removed lines. Original line number Diff line number Diff line Loading @@ -177,7 +177,8 @@ namespace authdb { _domainbck=nullptr; } authdb::AuthBackend *DomainBackend::data(::uuid::uuid did){ DomainInfo DomainBackend::resolve(::uuid::uuid did){ DomainInfo info; size_t rd=sizeof(authdb::AuthHeader),end=_adminbck.end(); while(rd<end){ Loading @@ -198,12 +199,26 @@ namespace authdb { Domain domain; domain.info(_adminbck,ddat,dpos); _domainbck = new AuthBackend(ddat.getStorageType(),ddat.getStorageOptions(),ddat.getDomainName()); return _domainbck; info.storageType = ddat.getStorageType(); info.storageOptions = ddat.getStorageOptions(); info.domainName = ddat.getDomainName(); info.found = true; return info; } } return info; } authdb::AuthBackend *DomainBackend::create(const DomainInfo &info){ if(!info.found) return nullptr; _domainbck = new AuthBackend(info.storageType,info.storageOptions,info.domainName); return _domainbck; } authdb::AuthBackend *DomainBackend::data(::uuid::uuid did){ DomainInfo info = resolve(did); return create(info); } DomainBackend::~DomainBackend(){ Loading