mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-07-26 07:55:44 -04:00
try to isolate pqistreamer mutex from pqissl mutex, step 1: pqistreamer::tick_recv()
This commit is contained in:
parent
07e71c3ea6
commit
d35dd76ca5
1 changed files with 29 additions and 12 deletions
|
@ -288,7 +288,14 @@ int pqistreamer::tick_bio()
|
||||||
|
|
||||||
int pqistreamer::tick_recv(uint32_t timeout)
|
int pqistreamer::tick_recv(uint32_t timeout)
|
||||||
{
|
{
|
||||||
RsStackMutex stack(mStreamerMtx); /**** LOCKED MUTEX ****/
|
// Only our thread manipulates mIncoming queue and related counters.
|
||||||
|
// The lock of pqistreamer mutex is thus not needed here.
|
||||||
|
// For the moment and for safety reasons it is still kept in 3 places:
|
||||||
|
// - in pqistreamer::tick_recv before calling free_pend_locked, as I dont know what this method actually does
|
||||||
|
// - in pqistreamer::handleincomingitem_locked, as it modifies mIncoming queue
|
||||||
|
// - in pqistreamer::inReadBytes_locked, as it modifies related counters
|
||||||
|
//
|
||||||
|
// RsStackMutex stack(mStreamerMtx); /**** LOCKED MUTEX ****/
|
||||||
|
|
||||||
if (mBio->moretoread(timeout))
|
if (mBio->moretoread(timeout))
|
||||||
{
|
{
|
||||||
|
@ -296,6 +303,9 @@ int pqistreamer::tick_recv(uint32_t timeout)
|
||||||
}
|
}
|
||||||
if(!(mBio->isactive()))
|
if(!(mBio->isactive()))
|
||||||
{
|
{
|
||||||
|
// lock only now, see comment above
|
||||||
|
RsStackMutex stack(mStreamerMtx); /**** LOCKED MUTEX ****/
|
||||||
|
|
||||||
free_pend_locked();
|
free_pend_locked();
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -414,6 +424,10 @@ int pqistreamer::handleincomingitem_locked(RsItem *pqi,int len)
|
||||||
|
|
||||||
// Use overloaded Contact function
|
// Use overloaded Contact function
|
||||||
pqi -> PeerId(PeerId());
|
pqi -> PeerId(PeerId());
|
||||||
|
|
||||||
|
// lock only now, see comment in pqistreamer::tick_recv
|
||||||
|
RsStackMutex stack(mStreamerMtx); /**** LOCKED MUTEX ****/
|
||||||
|
|
||||||
mIncoming.push_back(pqi);
|
mIncoming.push_back(pqi);
|
||||||
++mIncomingSize ;
|
++mIncomingSize ;
|
||||||
|
|
||||||
|
@ -1241,6 +1255,9 @@ void pqistreamer::inReadBytes_locked(uint32_t inb)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// lock only now, see comment in pqistreamer::tick_recv
|
||||||
|
RsStackMutex stack(mStreamerMtx); /**** LOCKED MUTEX ****/
|
||||||
|
|
||||||
mTotalRead += inb;
|
mTotalRead += inb;
|
||||||
mCurrRead += inb;
|
mCurrRead += inb;
|
||||||
mAvgReadCount += inb;
|
mAvgReadCount += inb;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue