# HG changeset patch # User Sam # Date 1684944021 -25200 # Node ID 76af5ffc0cb58f6d105f50d22f65d429409996fa # Parent e54339222a57c402c40408b8a05c61e99486c14f fix: issue with shared heap memory in settings diff -r e54339222a57 -r 76af5ffc0cb5 src/semicongine/settings.nim --- a/src/semicongine/settings.nim Wed May 24 22:59:55 2023 +0700 +++ b/src/semicongine/settings.nim Wed May 24 23:00:21 2023 +0700 @@ -1,4 +1,5 @@ import std/logging +import std/streams import std/parsecfg import std/strutils import std/sequtils @@ -11,7 +12,7 @@ when CONFIGHOTRELOAD: var - configUpdates: Channel[(string, Config)] + configUpdates: Channel[(string, string)] notifyConfigUpdate: Channel[bool] configUpdates.open() notifyConfigUpdate.open() @@ -49,7 +50,7 @@ when CONFIGHOTRELOAD: while configUpdates.peek() > 0: let (updatedNamespace, updatedConfig) = configUpdates.recv() - allsettings[updatedNamespace] = updatedConfig + allsettings[updatedNamespace] = loadConfig(newStringStream(updatedConfig)) if not allsettings.hasKey(namespace): raise newException(Exception, &"Namespace {namespace} not found, available namespaces are {allsettings.keys().toSeq}") allsettings[namespace].getSectionValue(section, key) @@ -95,7 +96,8 @@ configModTimes[namespace] = Time() let lastMod = namespace.getFile().getLastModificationTime() if lastMod != configModTimes[namespace]: - configUpdates.send((namespace, namespace.getFile().loadConfig())) + let configStr = newFileStream(namespace.getFile()).readAll() + configUpdates.send((namespace, configStr)) notifyConfigUpdate.send(true) sleep CONFIGHOTRELOADINTERVAL var thethread: Thread[void]