From 57be2cb11ee7d603b04fb1f1236721d2116d5985 Mon Sep 17 00:00:00 2001 From: Gioacchino Mazzurco Date: Sun, 8 Mar 2020 22:07:12 +0100 Subject: [PATCH] Silence excessive debugging in miniupnp handler --- .../src/rs_upnp/upnphandler_miniupnp.cc | 24 +++++++------------ .../src/rs_upnp/upnphandler_miniupnp.h | 5 ++-- 2 files changed, 12 insertions(+), 17 deletions(-) diff --git a/libretroshare/src/rs_upnp/upnphandler_miniupnp.cc b/libretroshare/src/rs_upnp/upnphandler_miniupnp.cc index 97b972cf1..ca21804af 100644 --- a/libretroshare/src/rs_upnp/upnphandler_miniupnp.cc +++ b/libretroshare/src/rs_upnp/upnphandler_miniupnp.cc @@ -642,14 +642,10 @@ void upnphandler::setExternalPort(unsigned short eport_in) dataMtx.unlock(); /*** UNLOCK MUTEX ***/ } - /* as determined by uPnP */ -bool upnphandler::getInternalAddress(struct sockaddr_storage &addr) +/* as determined by uPnP */ +bool upnphandler::getInternalAddress(struct sockaddr_storage &addr) { -// std::cerr << "UPnPHandler::getInternalAddress() pre Lock!" << std::endl; - dataMtx.lock(); /*** LOCK MUTEX ***/ -// std::cerr << "UPnPHandler::getInternalAddress() postLock!" << std::endl; - - std::cerr << "UPnPHandler::getInternalAddress()" << std::endl; + RS_STACK_MUTEX(dataMtx); // copy to universal addr. sockaddr_storage_clear(addr); @@ -657,18 +653,15 @@ bool upnphandler::getInternalAddress(struct sockaddr_storage &addr) bool valid = (upnpState >= RS_UPNP_S_ACTIVE); - dataMtx.unlock(); /*** UNLOCK MUTEX ***/ + Dbg2() << __PRETTY_FUNCTION__ << " valid: " << valid + << " addr: " << addr << std::endl; return valid; } -bool upnphandler::getExternalAddress(struct sockaddr_storage &addr) +bool upnphandler::getExternalAddress(sockaddr_storage &addr) { -// std::cerr << "UPnPHandler::getExternalAddress() pre Lock!" << std::endl; - dataMtx.lock(); /*** LOCK MUTEX ***/ -// std::cerr << "UPnPHandler::getExternalAddress() postLock!" << std::endl; - - std::cerr << "UPnPHandler::getExternalAddress()" << std::endl; + RS_STACK_MUTEX(dataMtx); // copy to universal addr. sockaddr_storage_clear(addr); @@ -676,7 +669,8 @@ bool upnphandler::getExternalAddress(struct sockaddr_storage &addr) bool valid = (upnpState == RS_UPNP_S_ACTIVE); - dataMtx.unlock(); /*** UNLOCK MUTEX ***/ + Dbg2() << __PRETTY_FUNCTION__ << " valid: " << valid + << " addr: " << addr << std::endl; return valid; } diff --git a/libretroshare/src/rs_upnp/upnphandler_miniupnp.h b/libretroshare/src/rs_upnp/upnphandler_miniupnp.h index d07304724..9449661e0 100644 --- a/libretroshare/src/rs_upnp/upnphandler_miniupnp.h +++ b/libretroshare/src/rs_upnp/upnphandler_miniupnp.h @@ -28,7 +28,7 @@ /* platform independent networking... */ #include "pqi/pqinetwork.h" #include "pqi/pqiassist.h" - +#include "util/rsdebug.h" #include "util/rsthreads.h" class upnpentry @@ -97,7 +97,7 @@ bool shutdown_upnp(); bool initUPnPState(); bool printUPnPState(); - private: +private: bool background_setup_upnp(bool, bool); bool checkUPnPActive(); @@ -123,4 +123,5 @@ bool checkUPnPActive(); /* active port forwarding */ std::list activeForwards; + RS_SET_CONTEXT_DEBUG_LEVEL(1) };