mirror of
https://github.com/vcmi/vcmi.git
synced 2024-12-24 22:14:36 +02:00
Attempt to fix headless tests crash.
This commit is contained in:
parent
a9c10633ab
commit
2c525fc76e
@ -188,7 +188,7 @@ int CBattleCallback::sendRequest(const CPack *request)
|
||||
{
|
||||
logGlobal->traceStream() << boost::format("We'll wait till request %d is answered.\n") % requestID;
|
||||
auto gsUnlocker = vstd::makeUnlockSharedGuardIf(CGameState::mutex, unlockGsWhenWaiting);
|
||||
cl->waitingRequest.waitWhileContains(requestID);
|
||||
CClient::waitingRequest.waitWhileContains(requestID);
|
||||
}
|
||||
|
||||
boost::this_thread::interruption_point();
|
||||
|
@ -59,6 +59,8 @@ extern std::string NAME;
|
||||
std::atomic_bool androidTestServerReadyFlag;
|
||||
#endif
|
||||
|
||||
ThreadSafeVector<int> CClient::waitingRequest;
|
||||
|
||||
template <typename T> class CApplyOnCL;
|
||||
|
||||
class CBaseForCLApply
|
||||
@ -109,6 +111,7 @@ static CApplier<CBaseForCLApply> *applier = nullptr;
|
||||
|
||||
void CClient::init()
|
||||
{
|
||||
waitingRequest.clear();
|
||||
hotSeat = false;
|
||||
connectionHandler = nullptr;
|
||||
pathInfo = nullptr;
|
||||
|
@ -72,6 +72,13 @@ class ThreadSafeVector
|
||||
boost::condition_variable cond;
|
||||
|
||||
public:
|
||||
void clear()
|
||||
{
|
||||
TLock lock(mx);
|
||||
items.clear();
|
||||
cond.notify_all();
|
||||
}
|
||||
|
||||
void pushBack(const T &item)
|
||||
{
|
||||
TLock lock(mx);
|
||||
@ -135,7 +142,7 @@ public:
|
||||
|
||||
CScriptingModule *erm;
|
||||
|
||||
ThreadSafeVector<int> waitingRequest;
|
||||
static ThreadSafeVector<int> waitingRequest;//FIXME: make this normal field (need to join all threads before client destruction)
|
||||
|
||||
void waitForMoveAndSend(PlayerColor color);
|
||||
//void sendRequest(const CPackForServer *request, bool waitForRealization);
|
||||
|
@ -775,7 +775,7 @@ void EndAction::applyCl(CClient *cl)
|
||||
void PackageApplied::applyCl(CClient *cl)
|
||||
{
|
||||
INTERFACE_CALL_IF_PRESENT(player, requestRealized, this);
|
||||
if(!cl->waitingRequest.tryRemovingElement(requestID))
|
||||
if(!CClient::waitingRequest.tryRemovingElement(requestID))
|
||||
logNetwork->warnStream() << "Surprising server message!";
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user