mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-18 08:28:32 +01:00
Corrected some things from the previous commit
This commit is contained in:
@@ -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();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user