summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2016-03-05 21:00:38 +0100
committerMax Kellermann <max@duempel.org>2016-03-05 21:00:38 +0100
commit031410c72b4622f265386c21fd1496e38779c2ba (patch)
treeb6acedd8ad46cb16413aead448780a4fd28b774e
parent710def8e381b39313e48184f51e60d9a13113259 (diff)
Instance: add StateFile* attribute
-rw-r--r--src/Instance.hxx3
-rw-r--r--src/Main.cxx20
2 files changed, 12 insertions, 11 deletions
diff --git a/src/Instance.hxx b/src/Instance.hxx
index ff0b484f0..99b8cd8ab 100644
--- a/src/Instance.hxx
+++ b/src/Instance.hxx
@@ -40,6 +40,7 @@ class UpdateService;
class Error;
class ClientList;
struct Partition;
+class StateFile;
struct Instance final
#if defined(ENABLE_DATABASE) || defined(ENABLE_NEIGHBOR_PLUGINS)
@@ -79,6 +80,8 @@ struct Instance final
Partition *partition;
+ StateFile *state_file;
+
Instance():global_events(event_loop) {}
/**
diff --git a/src/Main.cxx b/src/Main.cxx
index 3798dd8fb..39b48be80 100644
--- a/src/Main.cxx
+++ b/src/Main.cxx
@@ -128,8 +128,6 @@ Context *context;
Instance *instance;
-static StateFile *state_file;
-
#ifdef ENABLE_DAEMON
static bool
@@ -284,10 +282,10 @@ glue_state_file_init(Error &error)
config_get_unsigned(ConfigOption::STATE_FILE_INTERVAL,
StateFile::DEFAULT_INTERVAL);
- state_file = new StateFile(std::move(path_fs), interval,
- *instance->partition,
- instance->event_loop);
- state_file->Read();
+ instance->state_file = new StateFile(std::move(path_fs), interval,
+ *instance->partition,
+ instance->event_loop);
+ instance->state_file->Read();
return true;
}
@@ -380,8 +378,8 @@ idle_event_emitted(void)
instance->client_list->IdleAdd(flags);
if (flags & (IDLE_PLAYLIST|IDLE_PLAYER|IDLE_MIXER|IDLE_OUTPUT) &&
- state_file != nullptr)
- state_file->CheckModified();
+ instance->state_file != nullptr)
+ instance->state_file->CheckModified();
}
#ifndef ANDROID
@@ -655,9 +653,9 @@ try {
instance->update->CancelAllAsync();
#endif
- if (state_file != nullptr) {
- state_file->Write();
- delete state_file;
+ if (instance->state_file != nullptr) {
+ instance->state_file->Write();
+ delete instance->state_file;
}
instance->partition->pc.Kill();