perl: ensure that stores are destroyed after aio roots

otherwise stores containing async objects will cause crashes during
shutdown. currently there are no such stores, but that will change.

Change-Id: I05d46ba6831c641774edfe6aa99aa7d0de457429
This commit is contained in:
eldritch horrors
2025-06-17 14:34:05 +02:00
parent bc33c21b8a
commit fa116c96f7
+6 -2
View File
@@ -34,11 +34,15 @@ static AsyncIoRoot & aio()
static ref<Store> store()
{
static std::optional<ref<Store>> _store;
auto & aioRoot = aio();
// SAFETY: this store will be destructed after its associated aio
// root because the root is initialized first (due to call above)
static thread_local std::optional<ref<Store>> _store;
if (!_store) {
try {
initLibStore();
_store = aio().blockOn(openStore());
_store = aioRoot.blockOn(openStore());
} catch (Error & e) {
croak("%s", e.what());
}