mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-01-11 23:49:38 -05:00
BUGFIX: Mutex remained locked if Upnp setup failed.
This caused the freezing on many people PCs. It happened if (1) Networking was set to Automatic. (2) UPnP was not available. But its fixed now! git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@513 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
32cfbb8c80
commit
77342705ea
@ -101,7 +101,7 @@ bool upnphandler::printUPnPState()
|
|||||||
std::cerr << "upnphandler::printUPnPState() ... locking";
|
std::cerr << "upnphandler::printUPnPState() ... locking";
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
|
|
||||||
dataMtx.lock(); /* LOCK MUTEX */
|
RsStackMutex stack(dataMtx); /* LOCK STACK MUTEX */
|
||||||
|
|
||||||
std::cerr << "upnphandler::printUPnPState() ... locked";
|
std::cerr << "upnphandler::printUPnPState() ... locked";
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
@ -118,16 +118,13 @@ bool upnphandler::printUPnPState()
|
|||||||
std::cerr << "UPNP not Ready" << std::endl;
|
std::cerr << "UPNP not Ready" << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
dataMtx.unlock(); /* UNLOCK MUTEX */
|
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool upnphandler::checkUPnPActive()
|
bool upnphandler::checkUPnPActive()
|
||||||
{
|
{
|
||||||
dataMtx.lock(); /* LOCK MUTEX */
|
RsStackMutex stack(dataMtx); /* LOCK STACK MUTEX */
|
||||||
|
|
||||||
|
|
||||||
uPnPConfigData *config = upnpConfig;
|
uPnPConfigData *config = upnpConfig;
|
||||||
if ((upnpState > RS_UPNP_S_READY) && (config))
|
if ((upnpState > RS_UPNP_S_READY) && (config))
|
||||||
@ -146,11 +143,6 @@ bool upnphandler::checkUPnPActive()
|
|||||||
|
|
||||||
snprintf(in_port1, 256, "%d", ntohs(localAddr.sin_port));
|
snprintf(in_port1, 256, "%d", ntohs(localAddr.sin_port));
|
||||||
snprintf(in_port2, 256, "%d", ntohs(localAddr.sin_port));
|
snprintf(in_port2, 256, "%d", ntohs(localAddr.sin_port));
|
||||||
snprintf(in_addr, 256, "%d.%d.%d.%d",
|
|
||||||
((localAddr.sin_addr.s_addr >> 0) & 0xff),
|
|
||||||
((localAddr.sin_addr.s_addr >> 8) & 0xff),
|
|
||||||
((localAddr.sin_addr.s_addr >> 16) & 0xff),
|
|
||||||
((localAddr.sin_addr.s_addr >> 24) & 0xff));
|
|
||||||
|
|
||||||
snprintf(in_addr, 256, "%d.%d.%d.%d",
|
snprintf(in_addr, 256, "%d.%d.%d.%d",
|
||||||
((linaddr >> 24) & 0xff),
|
((linaddr >> 24) & 0xff),
|
||||||
@ -184,8 +176,6 @@ bool upnphandler::checkUPnPActive()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
dataMtx.unlock(); /* UNLOCK MUTEX */
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -244,11 +234,13 @@ bool upnphandler::background_setup_upnp(bool start, bool stop)
|
|||||||
|
|
||||||
bool upnphandler::start_upnp()
|
bool upnphandler::start_upnp()
|
||||||
{
|
{
|
||||||
dataMtx.lock(); /* LOCK MUTEX */
|
RsStackMutex stack(dataMtx); /* LOCK STACK MUTEX */
|
||||||
|
|
||||||
uPnPConfigData *config = upnpConfig;
|
uPnPConfigData *config = upnpConfig;
|
||||||
if (!((upnpState >= RS_UPNP_S_READY) && (config)))
|
if (!((upnpState >= RS_UPNP_S_READY) && (config)))
|
||||||
{
|
{
|
||||||
|
std::cerr << "upnphandler::start_upnp() Not Ready";
|
||||||
|
std::cerr << std::endl;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -344,15 +336,13 @@ bool upnphandler::start_upnp()
|
|||||||
|
|
||||||
toStart = false;
|
toStart = false;
|
||||||
|
|
||||||
dataMtx.unlock(); /* UNLOCK MUTEX */
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool upnphandler::shutdown_upnp()
|
bool upnphandler::shutdown_upnp()
|
||||||
{
|
{
|
||||||
dataMtx.lock(); /* LOCK MUTEX */
|
RsStackMutex stack(dataMtx); /* LOCK STACK MUTEX */
|
||||||
|
|
||||||
uPnPConfigData *config = upnpConfig;
|
uPnPConfigData *config = upnpConfig;
|
||||||
if (!((upnpState >= RS_UPNP_S_READY) && (config)))
|
if (!((upnpState >= RS_UPNP_S_READY) && (config)))
|
||||||
@ -392,8 +382,6 @@ bool upnphandler::shutdown_upnp()
|
|||||||
toStop = false;
|
toStop = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
dataMtx.unlock(); /* UNLOCK MUTEX */
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user