Commit 2f649c9a authored by bencefr's avatar bencefr
Browse files

Fixed serialization transport to access queue in a safe manner

parent 3fcdc514
......@@ -160,12 +160,15 @@ uint32_t SerializationTransport::send(uint8_t *cmdBuffer, uint32_t cmdLength, ui
// Event Thread
void SerializationTransport::eventHandlingRunner()
{
while (runEventThread) {
do {
std::unique_lock<std::mutex> eventLock(eventMutex);
eventWaitCondition.wait(eventLock);
while (!eventQueue.empty())
{
eventData_t eventData = eventQueue.front();
eventQueue.pop();
eventLock.unlock();
// Allocate memory to store decoded event including an unknown quantity of padding
// Set security context
......@@ -188,22 +191,10 @@ void SerializationTransport::eventHandlingRunner()
}
free(eventData.data);
}
std::unique_lock<std::mutex> eventLock(eventMutex);
if (!runEventThread)
{
break;
}
if (!eventQueue.empty())
{
continue;
eventLock.lock();
}
eventWaitCondition.wait(eventLock);
}
} while (runEventThread);
}
// Read Thread
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment