Fix Mutex in pqipersongrp for pqilistener by adding local Mutex.

This commit is contained in:
Phenom 2016-05-18 19:15:37 +02:00
parent 9f560696e9
commit af5129c26d
2 changed files with 8 additions and 7 deletions

View File

@ -140,7 +140,7 @@ int pqipersongrp::tickServiceSend()
// init
pqipersongrp::pqipersongrp(p3ServiceControl *ctrl, unsigned long flags)
:pqihandler(), p3ServiceServer(this, ctrl), pqil(NULL), initFlags(flags)
:pqihandler(), p3ServiceServer(this, ctrl), pqil(NULL), pqilMtx("pqipersongrp"), initFlags(flags)
{
}
@ -152,7 +152,7 @@ int pqipersongrp::tick()
*/
{
RsStackMutex stack(coreMtx); /******* LOCKED MUTEX **********/
RsStackMutex stack(pqilMtx); /******* LOCKED MUTEX **********/
if (pqil)
{
pqil -> tick();
@ -196,7 +196,7 @@ int pqipersongrp::tick()
int pqipersongrp::status()
{
{
RsStackMutex stack(coreMtx); /******* LOCKED MUTEX **********/
RsStackMutex stack(pqilMtx); /******* LOCKED MUTEX **********/
if (pqil)
{
pqil -> status();
@ -213,7 +213,7 @@ int pqipersongrp::init_listener()
/* extract our information from the p3ConnectMgr */
if (initFlags & PQIPERSON_NO_LISTENER)
{
RsStackMutex stack(coreMtx); /******* LOCKED MUTEX **********/
RsStackMutex stack(pqilMtx); /******* LOCKED MUTEX **********/
pqil = NULL;
}
else
@ -223,7 +223,7 @@ int pqipersongrp::init_listener()
struct sockaddr_storage laddr;
mLinkMgr->getLocalAddress(laddr);
RsStackMutex stack(coreMtx); /******* LOCKED MUTEX **********/
RsStackMutex stack(pqilMtx); /******* LOCKED MUTEX **********/
pqil = locked_createListener(laddr);
}
return 1;
@ -239,7 +239,7 @@ bool pqipersongrp::resetListener(const struct sockaddr_storage &local)
// change the address.
// restart.
RsStackMutex stack(coreMtx); /******* LOCKED MUTEX **********/
RsStackMutex stack(pqilMtx); /******* LOCKED MUTEX **********/
if (pqil != NULL)
{
@ -410,7 +410,7 @@ int pqipersongrp::addPeer(const RsPeerId& id)
{
// The Mutex is required here as pqiListener is not thread-safe.
RsStackMutex stack(coreMtx); /******* LOCKED MUTEX **********/
RsStackMutex stack(pqilMtx); /******* LOCKED MUTEX **********/
pqiperson *pqip = locked_createPerson(id, pqil);
// attach to pqihandler

View File

@ -123,6 +123,7 @@ virtual int checkOutgoingRsItem(RsItem *item, int global)
//int tickServiceSend();
pqilistener *pqil;
RsMutex pqilMtx; /* MUTEX */
unsigned long initFlags;
};