mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
added missing locks
git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@3841 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
b7badd980f
commit
02d228b94b
@ -88,6 +88,7 @@ p3BitDht::p3BitDht(std::string id, pqiConnectCb *cb, UdpStack *udpstack, std::st
|
|||||||
bdStdPrintNodeId(std::cerr, &ownId);
|
bdStdPrintNodeId(std::cerr, &ownId);
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
|
|
||||||
|
RsStackMutex stack(dhtMtx);
|
||||||
|
|
||||||
/* standard dht behaviour */
|
/* standard dht behaviour */
|
||||||
bdDhtFunctions *stdfns = new bdStdDht();
|
bdDhtFunctions *stdfns = new bdStdDht();
|
||||||
@ -108,6 +109,7 @@ p3BitDht::p3BitDht(std::string id, pqiConnectCb *cb, UdpStack *udpstack, std::st
|
|||||||
p3BitDht::~p3BitDht()
|
p3BitDht::~p3BitDht()
|
||||||
{
|
{
|
||||||
//udpstack->removeReceiver(mUdpBitDht);
|
//udpstack->removeReceiver(mUdpBitDht);
|
||||||
|
RsStackMutex stack(dhtMtx);
|
||||||
delete mUdpBitDht;
|
delete mUdpBitDht;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -116,6 +118,7 @@ void p3BitDht::start()
|
|||||||
std::cerr << "p3BitDht::start()";
|
std::cerr << "p3BitDht::start()";
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
|
|
||||||
|
RsStackMutex stack(dhtMtx);
|
||||||
mUdpBitDht->start(); /* starts up the bitdht thread */
|
mUdpBitDht->start(); /* starts up the bitdht thread */
|
||||||
|
|
||||||
/* dht switched on by config later. */
|
/* dht switched on by config later. */
|
||||||
@ -129,38 +132,45 @@ void p3BitDht::enable(bool on)
|
|||||||
|
|
||||||
if (on)
|
if (on)
|
||||||
{
|
{
|
||||||
|
RsStackMutex stack(dhtMtx);
|
||||||
mUdpBitDht->startDht();
|
mUdpBitDht->startDht();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
RsStackMutex stack(dhtMtx);
|
||||||
mUdpBitDht->stopDht();
|
mUdpBitDht->stopDht();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void p3BitDht::shutdown() /* blocking call */
|
void p3BitDht::shutdown() /* blocking call */
|
||||||
{
|
{
|
||||||
|
RsStackMutex stack(dhtMtx);
|
||||||
mUdpBitDht->stopDht();
|
mUdpBitDht->stopDht();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void p3BitDht::restart()
|
void p3BitDht::restart()
|
||||||
{
|
{
|
||||||
|
RsStackMutex stack(dhtMtx);
|
||||||
mUdpBitDht->stopDht();
|
mUdpBitDht->stopDht();
|
||||||
mUdpBitDht->startDht();
|
mUdpBitDht->startDht();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool p3BitDht::getEnabled()
|
bool p3BitDht::getEnabled()
|
||||||
{
|
{
|
||||||
|
RsStackMutex stack(dhtMtx);
|
||||||
return (mUdpBitDht->stateDht() != 0);
|
return (mUdpBitDht->stateDht() != 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool p3BitDht::getActive()
|
bool p3BitDht::getActive()
|
||||||
{
|
{
|
||||||
|
RsStackMutex stack(dhtMtx);
|
||||||
return (mUdpBitDht->stateDht() >= BITDHT_MGR_STATE_ACTIVE);
|
return (mUdpBitDht->stateDht() >= BITDHT_MGR_STATE_ACTIVE);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool p3BitDht::getNetworkStats(uint32_t &netsize, uint32_t &localnetsize)
|
bool p3BitDht::getNetworkStats(uint32_t &netsize, uint32_t &localnetsize)
|
||||||
{
|
{
|
||||||
|
RsStackMutex stack(dhtMtx);
|
||||||
netsize = mUdpBitDht->statsNetworkSize();
|
netsize = mUdpBitDht->statsNetworkSize();
|
||||||
localnetsize = mUdpBitDht->statsBDVersionSize();
|
localnetsize = mUdpBitDht->statsBDVersionSize();
|
||||||
return true;
|
return true;
|
||||||
@ -197,6 +207,7 @@ bool p3BitDht::findPeer(std::string pid)
|
|||||||
bdStdPrintNodeId(std::cerr, &nid);
|
bdStdPrintNodeId(std::cerr, &nid);
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
|
|
||||||
|
RsStackMutex stack(dhtMtx);
|
||||||
/* add in peer */
|
/* add in peer */
|
||||||
mUdpBitDht->addFindNode(&nid, BITDHT_QFLAGS_DO_IDLE);
|
mUdpBitDht->addFindNode(&nid, BITDHT_QFLAGS_DO_IDLE);
|
||||||
|
|
||||||
@ -223,8 +234,11 @@ bool p3BitDht::dropPeer(std::string pid)
|
|||||||
bdStdPrintNodeId(std::cerr, &nid);
|
bdStdPrintNodeId(std::cerr, &nid);
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
|
|
||||||
|
{
|
||||||
|
RsStackMutex stack(dhtMtx);
|
||||||
/* remove in peer */
|
/* remove in peer */
|
||||||
mUdpBitDht->removeFindNode(&nid);
|
mUdpBitDht->removeFindNode(&nid);
|
||||||
|
}
|
||||||
|
|
||||||
/* remove from translation */
|
/* remove from translation */
|
||||||
if (!removeTranslation(pid))
|
if (!removeTranslation(pid))
|
||||||
|
Loading…
Reference in New Issue
Block a user