diff --git a/libretroshare/src/upnp/UPnPBase.cpp b/libretroshare/src/upnp/UPnPBase.cpp index 679d3157d..6d0bfd79a 100644 --- a/libretroshare/src/upnp/UPnPBase.cpp +++ b/libretroshare/src/upnp/UPnPBase.cpp @@ -697,32 +697,6 @@ bool CUPnPService::Execute( static_cast(&CUPnPControlPoint::Callback), NULL); return true; - -// std::cerr << "Calling UpnpSendAction." << std::endl; -// // Send the action synchronously -// IXML_Document *RespDoc = NULL; -// int ret = UpnpSendAction( -// m_UPnPControlPoint.GetUPnPClientHandle(), -// GetAbsControlURL().c_str(), -// GetServiceType().c_str(), -// NULL, ActionDoc, &RespDoc); -// if (ret != UPNP_E_SUCCESS) { -// m_upnpLib.processUPnPErrorMessage( -// "UpnpSendAction", ret, NULL, RespDoc); -// ixmlDocument_free(ActionDoc); -// ixmlDocument_free(RespDoc); -// return false; -// } -// ixmlDocument_free(ActionDoc); -// -// // Check the response document -// m_upnpLib.ProcessActionResponse( -// RespDoc, action.GetName()); -// -// // Free the response document -// ixmlDocument_free(RespDoc); -// -// return true; } @@ -887,7 +861,7 @@ m_WanService(NULL) #ifdef UPNP_DEBUG std::cerr << "CUPnPControlPoint Constructor UpnpInit finished" << std::endl; #endif - if (ret != UPNP_E_SUCCESS) { + if (ret != UPNP_E_SUCCESS && ret !=UPNP_E_INIT) { std::cerr << "error(UpnpInit): Error code : "; goto error; } diff --git a/libretroshare/src/upnp/upnphandler.cc b/libretroshare/src/upnp/upnphandler.cc index 450b88ce3..a5c34fad4 100644 --- a/libretroshare/src/upnp/upnphandler.cc +++ b/libretroshare/src/upnp/upnphandler.cc @@ -191,11 +191,12 @@ bool upnphandler::shutdown_upnp() //stopping os ok, set starting to true for next net reset toStop = false; toStart = true; + upnpState = RS_UPNP_S_UNINITIALISED; /* always attempt this (unless no port number) */ - if (eport_curr > 0 && eport > 0) + if (eport_curr > 0 && eport > 0 && (upnpState >= RS_UPNP_S_ACTIVE)) { - std::cerr << "Attempting To Remove Redirection: port: " << eport_curr; + std::cerr << "upnphandler::shutdown_upnp() : Attempting To Remove Redirection: port: " << eport_curr; std::cerr << " Prot: TCP"; std::cerr << std::endl; @@ -204,7 +205,7 @@ bool upnphandler::shutdown_upnp() upnpPortMapping1.push_back(cUPnPPortMapping1); cUPnPControlPoint->DeletePortMappings(upnpPortMapping1); - std::cerr << "Attempting To Remove Redirection: port: " << eport_curr; + std::cerr << " : Attempting To Remove Redirection: port: " << eport_curr; std::cerr << " Prot: UDP"; std::cerr << std::endl; @@ -216,6 +217,10 @@ bool upnphandler::shutdown_upnp() //destroy the upnp object cUPnPControlPoint->~CUPnPControlPoint(); upnpState = RS_UPNP_S_UNINITIALISED; + } else { + #ifdef CONN_DEBUG + std::cerr << "upnphandler::shutdown_upnp() : avoid upnp connection for shutdows A net flag went down." << std::endl; + #endif } return true;