mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
Merge pull request #390 from PhenomRetroShare/Fix_MutexInPqiPersonGrp
Fix Mutex in pqipersongrp for pqilistener by adding local Mutex.
This commit is contained in:
commit
4c5c09cbc8
@ -140,7 +140,7 @@ int pqipersongrp::tickServiceSend()
|
|||||||
|
|
||||||
// init
|
// init
|
||||||
pqipersongrp::pqipersongrp(p3ServiceControl *ctrl, unsigned long flags)
|
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)
|
if (pqil)
|
||||||
{
|
{
|
||||||
pqil -> tick();
|
pqil -> tick();
|
||||||
@ -196,7 +196,7 @@ int pqipersongrp::tick()
|
|||||||
int pqipersongrp::status()
|
int pqipersongrp::status()
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
RsStackMutex stack(coreMtx); /******* LOCKED MUTEX **********/
|
RsStackMutex stack(pqilMtx); /******* LOCKED MUTEX **********/
|
||||||
if (pqil)
|
if (pqil)
|
||||||
{
|
{
|
||||||
pqil -> status();
|
pqil -> status();
|
||||||
@ -213,7 +213,7 @@ int pqipersongrp::init_listener()
|
|||||||
/* extract our information from the p3ConnectMgr */
|
/* extract our information from the p3ConnectMgr */
|
||||||
if (initFlags & PQIPERSON_NO_LISTENER)
|
if (initFlags & PQIPERSON_NO_LISTENER)
|
||||||
{
|
{
|
||||||
RsStackMutex stack(coreMtx); /******* LOCKED MUTEX **********/
|
RsStackMutex stack(pqilMtx); /******* LOCKED MUTEX **********/
|
||||||
pqil = NULL;
|
pqil = NULL;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -223,7 +223,7 @@ int pqipersongrp::init_listener()
|
|||||||
struct sockaddr_storage laddr;
|
struct sockaddr_storage laddr;
|
||||||
mLinkMgr->getLocalAddress(laddr);
|
mLinkMgr->getLocalAddress(laddr);
|
||||||
|
|
||||||
RsStackMutex stack(coreMtx); /******* LOCKED MUTEX **********/
|
RsStackMutex stack(pqilMtx); /******* LOCKED MUTEX **********/
|
||||||
pqil = locked_createListener(laddr);
|
pqil = locked_createListener(laddr);
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
@ -239,7 +239,7 @@ bool pqipersongrp::resetListener(const struct sockaddr_storage &local)
|
|||||||
// change the address.
|
// change the address.
|
||||||
// restart.
|
// restart.
|
||||||
|
|
||||||
RsStackMutex stack(coreMtx); /******* LOCKED MUTEX **********/
|
RsStackMutex stack(pqilMtx); /******* LOCKED MUTEX **********/
|
||||||
|
|
||||||
if (pqil != NULL)
|
if (pqil != NULL)
|
||||||
{
|
{
|
||||||
@ -410,7 +410,7 @@ int pqipersongrp::addPeer(const RsPeerId& id)
|
|||||||
|
|
||||||
{
|
{
|
||||||
// The Mutex is required here as pqiListener is not thread-safe.
|
// 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);
|
pqiperson *pqip = locked_createPerson(id, pqil);
|
||||||
|
|
||||||
// attach to pqihandler
|
// attach to pqihandler
|
||||||
|
@ -123,6 +123,7 @@ virtual int checkOutgoingRsItem(RsItem *item, int global)
|
|||||||
//int tickServiceSend();
|
//int tickServiceSend();
|
||||||
|
|
||||||
pqilistener *pqil;
|
pqilistener *pqil;
|
||||||
|
RsMutex pqilMtx; /* MUTEX */
|
||||||
unsigned long initFlags;
|
unsigned long initFlags;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user