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:
drbob 2008-04-22 11:45:28 +00:00
parent 32cfbb8c80
commit 77342705ea

View File

@ -101,7 +101,7 @@ bool upnphandler::printUPnPState()
std::cerr << "upnphandler::printUPnPState() ... locking";
std::cerr << std::endl;
dataMtx.lock(); /* LOCK MUTEX */
RsStackMutex stack(dataMtx); /* LOCK STACK MUTEX */
std::cerr << "upnphandler::printUPnPState() ... locked";
std::cerr << std::endl;
@ -118,16 +118,13 @@ bool upnphandler::printUPnPState()
std::cerr << "UPNP not Ready" << std::endl;
}
dataMtx.unlock(); /* UNLOCK MUTEX */
return 1;
}
bool upnphandler::checkUPnPActive()
{
dataMtx.lock(); /* LOCK MUTEX */
RsStackMutex stack(dataMtx); /* LOCK STACK MUTEX */
uPnPConfigData *config = upnpConfig;
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_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",
((linaddr >> 24) & 0xff),
@ -184,8 +176,6 @@ bool upnphandler::checkUPnPActive()
}
}
dataMtx.unlock(); /* UNLOCK MUTEX */
return true;
}
@ -244,11 +234,13 @@ bool upnphandler::background_setup_upnp(bool start, bool stop)
bool upnphandler::start_upnp()
{
dataMtx.lock(); /* LOCK MUTEX */
RsStackMutex stack(dataMtx); /* LOCK STACK MUTEX */
uPnPConfigData *config = upnpConfig;
if (!((upnpState >= RS_UPNP_S_READY) && (config)))
{
std::cerr << "upnphandler::start_upnp() Not Ready";
std::cerr << std::endl;
return false;
}
@ -344,15 +336,13 @@ bool upnphandler::start_upnp()
toStart = false;
dataMtx.unlock(); /* UNLOCK MUTEX */
return true;
}
bool upnphandler::shutdown_upnp()
{
dataMtx.lock(); /* LOCK MUTEX */
RsStackMutex stack(dataMtx); /* LOCK STACK MUTEX */
uPnPConfigData *config = upnpConfig;
if (!((upnpState >= RS_UPNP_S_READY) && (config)))
@ -392,8 +382,6 @@ bool upnphandler::shutdown_upnp()
toStop = false;
}
dataMtx.unlock(); /* UNLOCK MUTEX */
return true;
}