mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-01-27 07:47:03 -05:00
fixed deadlock in UDP connections. Still, UDP streams break after 5-10 secs. Needs further debugging.
git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@7529 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
e07dac9ca7
commit
0c536c3f4c
@ -648,8 +648,25 @@ void pqiperson::setMaxRate(bool in, float val)
|
||||
|
||||
void pqiperson::setRateCap(float val_in, float val_out)
|
||||
{
|
||||
// This methods might be called all the way down from pqiperson::tick() down
|
||||
// to pqissludp while completing a UDP connexion, causing a deadlock.
|
||||
//
|
||||
// We need to make sure the mutex is not already locked by current thread. If so, we call the
|
||||
// locked version directly if not, we lock, call, and unlock, possibly waiting if the
|
||||
// lock is already acquired by another thread.
|
||||
//
|
||||
// The lock cannot be locked by the same thread between the first test and
|
||||
// the "else" statement, so there is no possibility for this code to fail.
|
||||
//
|
||||
// We could actually put that code in RsMutex::lock()
|
||||
|
||||
if(pthread_equal(mPersonMtx.owner(),pthread_self())) // 1 - unlocked, or already locked by same thread
|
||||
return setRateCap_locked(val_in, val_out); // -> do nothing
|
||||
else
|
||||
{ // 2 - lock was free or locked by different thread => wait.
|
||||
RsStackMutex stack(mPersonMtx); /**** LOCK MUTEX ****/
|
||||
return setRateCap_locked(val_in, val_out);
|
||||
setRateCap_locked(val_in, val_out);
|
||||
}
|
||||
}
|
||||
|
||||
void pqiperson::setRateCap_locked(float val_in, float val_out)
|
||||
|
@ -58,6 +58,7 @@ class RsMutex
|
||||
pthread_mutex_destroy(&realMutex);
|
||||
}
|
||||
|
||||
inline const pthread_t& owner() const { return _thread_id ; }
|
||||
#ifdef RSMUTEX_DEBUG
|
||||
void setName(const std::string &name)
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user