Avoid netReset() if no network address is available

This commit is contained in:
Gioacchino Mazzurco 2019-09-28 18:42:13 +02:00
parent c07f93992c
commit 6788ea041a
No known key found for this signature in database
GPG key ID: A1FBCA3872E87051
2 changed files with 13 additions and 47 deletions

View file

@ -3,8 +3,8 @@
* * * *
* libretroshare: retroshare core library * * libretroshare: retroshare core library *
* * * *
* Copyright 2007-2011 by Robert Fernie. * * Copyright (C) 2007-2011 Robert Fernie <retroshare@lunamutt.com> *
* Copyright (C) 2015-2018 Gioacchino Mazzurco <gio@eigenlab.org> * * Copyright (C) 2015-2019 Gioacchino Mazzurco <gio@eigenlab.org> *
* * * *
* This program is free software: you can redistribute it and/or modify * * This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License as * * it under the terms of the GNU Lesser General Public License as *
@ -1037,15 +1037,10 @@ bool p3NetMgrIMPL::checkNetAddress()
} }
} }
/* if we don't have a valid address - reset */
if (!validAddr) if (!validAddr)
{ {
#ifdef NETMGR_DEBUG_RESET Dbg3() << __PRETTY_FUNCTION__ << " no valid local network address found"
std::cerr << "p3NetMgrIMPL::checkNetAddress() no Valid Network Address, resetting network." << std::endl; << std::endl;
#endif
rslog(RSL_WARNING, p3netmgrzone, "p3NetMgr::checkNetAddress() No Valid Network Address, resetting network");
netReset();
return false; return false;
} }
@ -2055,4 +2050,4 @@ void p3NetMgrIMPL::updateNetStateBox_reset()
} }
} }
p3NetMgr::~p3NetMgr() = default;

View file

@ -3,7 +3,8 @@
* * * *
* libretroshare: retroshare core library * * libretroshare: retroshare core library *
* * * *
* Copyright 2007-2008 by Robert Fernie <retroshare@lunamutt.com> * * Copyright (C) 2007-2008 Robert Fernie <retroshare@lunamutt.com> *
* Copyright (C) 2015-2019 Gioacchino Mazzurco <gio@eigenlab.org> *
* * * *
* This program is free software: you can redistribute it and/or modify * * This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License as * * it under the terms of the GNU Lesser General Public License as *
@ -19,21 +20,15 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * * along with this program. If not, see <https://www.gnu.org/licenses/>. *
* * * *
*******************************************************************************/ *******************************************************************************/
#ifndef MRK_PQI_NET_MANAGER_HEADER #pragma once
#define MRK_PQI_NET_MANAGER_HEADER
#include "pqi/pqimonitor.h" #include "pqi/pqimonitor.h"
#include "pqi/pqiipset.h" #include "pqi/pqiipset.h"
//#include "pqi/p3dhtmgr.h"
//#include "pqi/p3upnpmgr.h"
#include "pqi/pqiassist.h" #include "pqi/pqiassist.h"
#include "pqi/pqinetstatebox.h" #include "pqi/pqinetstatebox.h"
#include "pqi/p3cfgmgr.h" #include "pqi/p3cfgmgr.h"
#include "util/rsthreads.h" #include "util/rsthreads.h"
#include "util/rsdebug.h"
class ExtAddrFinder ; class ExtAddrFinder ;
class DNSResolver ; class DNSResolver ;
@ -101,11 +96,7 @@ class UdpRelayReceiver;
class p3NetMgr class p3NetMgr
{ {
public: public:
p3NetMgr() { return; }
virtual ~p3NetMgr() { return; }
/*************** External Control ****************/ /*************** External Control ****************/
@ -144,18 +135,13 @@ virtual bool getUPnPState() = 0;
virtual bool getUPnPEnabled() = 0; virtual bool getUPnPEnabled() = 0;
virtual bool getDHTEnabled() = 0; virtual bool getDHTEnabled() = 0;
virtual ~p3NetMgr();
/************************************************************************************************/
/************************************************************************************************/
/************************************************************************************************/
/************************************************************************************************/
}; };
class p3NetMgrIMPL: public p3NetMgr class p3NetMgrIMPL: public p3NetMgr
{ {
public: public:
p3NetMgrIMPL(); p3NetMgrIMPL();
@ -229,20 +215,6 @@ protected:
void slowTick(); void slowTick();
/* THESE FUNCTIONS ARE ON_LONGER EXTERNAL - CAN THEY BE REMOVED? */
//bool getDHTStats(uint32_t &netsize, uint32_t &localnetsize);
//bool getNetStatusLocalOk();
//bool getNetStatusUpnpOk();
//bool getNetStatusDhtOk();
//bool getNetStatusStunOk();
//bool getNetStatusExtraAddressCheckOk();
//bool getUpnpExtAddress(struct sockaddr_in &addr);
//bool getExtFinderAddress(struct sockaddr_in &addr);
//void setOwnNetConfig(uint32_t netMode, uint32_t visState);
protected: protected:
/****************** Internal Interface *******************/ /****************** Internal Interface *******************/
@ -367,6 +339,5 @@ void netStatusReset_locked();
uint32_t mOldNatType; uint32_t mOldNatType;
uint32_t mOldNatHole; uint32_t mOldNatHole;
RS_SET_CONTEXT_DEBUG_LEVEL(2)
}; };
#endif // MRK_PQI_NET_MANAGER_HEADER