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;
|
logGlobal->traceStream() << boost::format("We'll wait till request %d is answered.\n") % requestID;
|
||||||
auto gsUnlocker = vstd::makeUnlockSharedGuardIf(CGameState::mutex, unlockGsWhenWaiting);
|
auto gsUnlocker = vstd::makeUnlockSharedGuardIf(CGameState::mutex, unlockGsWhenWaiting);
|
||||||
cl->waitingRequest.waitWhileContains(requestID);
|
CClient::waitingRequest.waitWhileContains(requestID);
|
||||||
}
|
}
|
||||||
|
|
||||||
boost::this_thread::interruption_point();
|
boost::this_thread::interruption_point();
|
||||||
|
@ -59,6 +59,8 @@ extern std::string NAME;
|
|||||||
std::atomic_bool androidTestServerReadyFlag;
|
std::atomic_bool androidTestServerReadyFlag;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
ThreadSafeVector<int> CClient::waitingRequest;
|
||||||
|
|
||||||
template <typename T> class CApplyOnCL;
|
template <typename T> class CApplyOnCL;
|
||||||
|
|
||||||
class CBaseForCLApply
|
class CBaseForCLApply
|
||||||
@ -109,6 +111,7 @@ static CApplier<CBaseForCLApply> *applier = nullptr;
|
|||||||
|
|
||||||
void CClient::init()
|
void CClient::init()
|
||||||
{
|
{
|
||||||
|
waitingRequest.clear();
|
||||||
hotSeat = false;
|
hotSeat = false;
|
||||||
connectionHandler = nullptr;
|
connectionHandler = nullptr;
|
||||||
pathInfo = nullptr;
|
pathInfo = nullptr;
|
||||||
|
@ -72,6 +72,13 @@ class ThreadSafeVector
|
|||||||
boost::condition_variable cond;
|
boost::condition_variable cond;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
void clear()
|
||||||
|
{
|
||||||
|
TLock lock(mx);
|
||||||
|
items.clear();
|
||||||
|
cond.notify_all();
|
||||||
|
}
|
||||||
|
|
||||||
void pushBack(const T &item)
|
void pushBack(const T &item)
|
||||||
{
|
{
|
||||||
TLock lock(mx);
|
TLock lock(mx);
|
||||||
@ -135,7 +142,7 @@ public:
|
|||||||
|
|
||||||
CScriptingModule *erm;
|
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 waitForMoveAndSend(PlayerColor color);
|
||||||
//void sendRequest(const CPackForServer *request, bool waitForRealization);
|
//void sendRequest(const CPackForServer *request, bool waitForRealization);
|
||||||
|
@ -775,7 +775,7 @@ void EndAction::applyCl(CClient *cl)
|
|||||||
void PackageApplied::applyCl(CClient *cl)
|
void PackageApplied::applyCl(CClient *cl)
|
||||||
{
|
{
|
||||||
INTERFACE_CALL_IF_PRESENT(player, requestRealized, this);
|
INTERFACE_CALL_IF_PRESENT(player, requestRealized, this);
|
||||||
if(!cl->waitingRequest.tryRemovingElement(requestID))
|
if(!CClient::waitingRequest.tryRemovingElement(requestID))
|
||||||
logNetwork->warnStream() << "Surprising server message!";
|
logNetwork->warnStream() << "Surprising server message!";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user