Fixed upnp issues

* Removed periodic Check and thread.
 * Added Shutdown.
 * switched to terminating background thread.
 * removed temporary lease.
 * A bit of a HACK - this class could be cleaned up significantly.

Adding the start of forums/channels.
 * Dummy Interface and Forum data (so GUI work can start)
 * rough p3distrib - needs a lot of work.

Added shutdown function to p3connmgr, to shutdown Upnp.



git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@493 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
drbob 2008-04-09 12:54:15 +00:00
parent 20c9e7d224
commit 94371600be
16 changed files with 2007 additions and 233 deletions

View file

@ -34,10 +34,10 @@ RSOBJ = $(BASE_OBJ) $(LOOP_OBJ) \
$(GRP_OBJ) \
$(OTHER_OBJ)
TESTOBJ = xpgp_id.o net_test.o dht_test.o
TESTOBJ = xpgp_id.o net_test.o dht_test.o net_test1.o
#conn_test.o
TESTS = xpgp_id net_test dht_test
TESTS = xpgp_id net_test dht_test net_test1
#conn_test
@ -55,6 +55,9 @@ conn_test: conn_test.o
net_test: net_test.o
$(CC) $(CFLAGS) -o net_test net_test.o $(LIBS)
net_test1: net_test1.o
$(CC) $(CFLAGS) -o net_test1 net_test1.o $(LIBS)
###############################################################
include $(RS_TOP_DIR)/scripts/rules.mk
###############################################################

View file

@ -45,7 +45,7 @@ const uint32_t RS_STUN_DONE = 0x0002;
const uint32_t RS_STUN_LIST_MIN = 100;
const uint32_t RS_STUN_FOUND_MIN = 10;
const uint32_t MAX_UPNP_INIT = 30; /* seconds UPnP timeout */
const uint32_t MAX_UPNP_INIT = 10; /* seconds UPnP timeout */
/****
* #define CONN_DEBUG 1
@ -300,6 +300,21 @@ void p3ConnectMgr::tick()
}
bool p3ConnectMgr::shutdown() /* blocking shutdown call */
{
connMtx.lock(); /* LOCK MUTEX */
bool upnpActive = ownState.netMode & RS_NET_MODE_UPNP;
connMtx.unlock(); /* UNLOCK MUTEX */
if (upnpActive)
{
mUpnpMgr->shutdownUPnP();
}
return true;
}
void p3ConnectMgr::statusTick()
{

View file

@ -165,6 +165,8 @@ void setUpnpMgr(p3UpnpMgr *umgr) { mUpnpMgr = umgr; }
bool checkNetAddress(); /* check our address is sensible */
/*************** External Control ****************/
bool shutdown(); /* blocking shutdown call */
bool retryConnect(std::string id);
bool getUPnPState();

View file

@ -31,15 +31,16 @@
#include "util/rsthreads.h"
#include "pqi/pqinetwork.h"
class p3UpnpMgr: public RsThread
class p3UpnpMgr
{
public:
virtual ~p3UpnpMgr() { return; }
/* External Interface */
virtual void enableUPnP(bool on) = 0;
virtual void shutdownUPnP() = 0;
virtual void enableUPnP(bool on) = 0; /* launches thread to start it up */
virtual void shutdownUPnP() = 0; /* blocking shutdown call */
virtual void restartUPnP() = 0; /* must be called if ports change */
virtual bool getUPnPEnabled() = 0;
virtual bool getUPnPActive() = 0;