diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/server/worldserver/TCSoap/TCSoap.cpp | 12 | ||||
-rw-r--r-- | src/server/worldserver/TCSoap/TCSoap.h | 5 |
2 files changed, 8 insertions, 9 deletions
diff --git a/src/server/worldserver/TCSoap/TCSoap.cpp b/src/server/worldserver/TCSoap/TCSoap.cpp index ba99967a485..5122752f3a4 100644 --- a/src/server/worldserver/TCSoap/TCSoap.cpp +++ b/src/server/worldserver/TCSoap/TCSoap.cpp @@ -56,7 +56,7 @@ void TCSoapThread(const std::string& host, uint16 port) void process_message(struct soap* soap_message) { - ACE_TRACE (ACE_TEXT ("SOAPWorkingThread::process_message")); + TC_LOG_TRACE("network.soap", "SOAPWorkingThread::process_message"); soap_serve(soap_message); soap_destroy(soap_message); // dealloc C++ data @@ -105,16 +105,15 @@ int ns1__executeCommand(soap* soap, char* command, char** result) // commands are executed in the world thread. We have to wait for them to be completed { - // CliCommandHolder will be deleted from world, accessing after queueing is NOT save + // CliCommandHolder will be deleted from world, accessing after queueing is NOT safe CliCommandHolder* cmd = new CliCommandHolder(&connection, command, &SOAPCommand::print, &SOAPCommand::commandFinished); sWorld->QueueCliCommand(cmd); } - // wait for callback to complete command - connection.pendingCommands.lock(); - - // alright, command finished + // Wait until the command has finished executing + connection.finishedPromise.get_future().wait(); + // The command has finished executing already char* printBuffer = soap_strdup(soap, connection.m_printBuffer.c_str()); if (connection.hasCommandSucceeded()) { @@ -129,7 +128,6 @@ void SOAPCommand::commandFinished(void* soapconnection, bool success) { SOAPCommand* con = (SOAPCommand*)soapconnection; con->setCommandSuccess(success); - con->pendingCommands.unlock(); } //////////////////////////////////////////////////////////////////////////////// diff --git a/src/server/worldserver/TCSoap/TCSoap.h b/src/server/worldserver/TCSoap/TCSoap.h index 0de5d2874f6..999a03a9009 100644 --- a/src/server/worldserver/TCSoap/TCSoap.h +++ b/src/server/worldserver/TCSoap/TCSoap.h @@ -20,6 +20,7 @@ #include "Define.h" #include <mutex> +#include <future> void process_message(struct soap* soap_message); void TCSoapThread(const std::string& host, uint16 port); @@ -41,11 +42,10 @@ class SOAPCommand m_printBuffer += msg; } - std::mutex pendingCommands; - void setCommandSuccess(bool val) { m_success = val; + finishedPromise.set_value(); } bool hasCommandSucceeded() const @@ -62,6 +62,7 @@ class SOAPCommand bool m_success; std::string m_printBuffer; + std::promise<void> finishedPromise; }; #endif |