Created
March 17, 2015 16:47
-
-
Save Roguelazer/60fd53f1a39b81480ffc to your computer and use it in GitHub Desktop.
livestatus mutex
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/livestatus/src/Store.cc b/livestatus/src/Store.cc | |
index e2fd4e0..2560105 100644 | |
--- a/livestatus/src/Store.cc | |
+++ b/livestatus/src/Store.cc | |
@@ -47,6 +47,7 @@ Store::Store() | |
, _table_servicesbyhostgroup(false, true) | |
, _table_downtimes(true) | |
, _table_comments(false) | |
+ , _command_mutex(PTHREAD_MUTEX_INITIALIZER) | |
{ | |
_tables.insert(make_pair("columns", &_table_columns)); | |
_tables.insert(make_pair("commands", &_table_commands)); | |
@@ -147,6 +148,7 @@ bool Store::answerRequest(InputBuffer *input, OutputBuffer *output) | |
void Store::answerCommandRequest(const char *command) | |
{ | |
+ pthread_mutex_lock(&_command_mutex); | |
#ifdef NAGIOS4 | |
process_external_command1((char *)command); | |
#else | |
@@ -154,6 +156,7 @@ void Store::answerCommandRequest(const char *command) | |
/* int ret = */ | |
submit_external_command((char *)command, &buffer_items); | |
#endif | |
+ pthread_mutex_unlock(&_command_mutex); | |
} | |
diff --git a/livestatus/src/Store.h b/livestatus/src/Store.h | |
index 5d72b41..082a94f 100644 | |
--- a/livestatus/src/Store.h | |
+++ b/livestatus/src/Store.h | |
@@ -77,6 +77,8 @@ public: | |
bool answerRequest(InputBuffer *, OutputBuffer *); | |
private: | |
+ pthread_mutex_t _command_mutex; | |
+ | |
Table *findTable(string name); | |
void answerGetRequest(InputBuffer *, OutputBuffer *, const char *); | |
void answerCommandRequest(const char *); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment