mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2026-10-08 13:53:45 +00:00
feat(cdclient): make a new CDServer.sqlite off-thread and swap tables in place
CDClientSnapshot converts a copy of the client's fdb into its own CDServer-<hash>.sqlite with the cdserver migrations applied, on its own connection. CDClientDatabase::Reconnect opens the new file before letting go of the old one; CDClientManager::Reload empties every table (old entries kept alive so references from spawned objects stay valid), retires the old fdb view and loads again. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -7,6 +7,7 @@
|
||||
|
||||
namespace {
|
||||
std::unique_ptr<FdbReader> g_Fdb;
|
||||
std::unique_ptr<FdbReader> g_Retired;
|
||||
|
||||
// Column name -> index for each table handed out by GetTable, so RowFields looks up names in O(1)
|
||||
std::unordered_map<const FdbReader::Table*, std::unordered_map<std::string, int32_t>> g_ColumnIndices;
|
||||
@@ -127,6 +128,11 @@ void CDFdb::Close() {
|
||||
g_Fdb.reset();
|
||||
}
|
||||
|
||||
void CDFdb::Retire() {
|
||||
g_ColumnIndices.clear();
|
||||
if (g_Fdb) g_Retired = std::move(g_Fdb);
|
||||
}
|
||||
|
||||
const FdbReader* CDFdb::Get() {
|
||||
return g_Fdb.get();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user