perform a net reset when network config is changed

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@1871 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
joss17 2009-12-14 13:46:23 +00:00
parent 274479bc41
commit b447a213ea

View File

@ -574,7 +574,7 @@ void p3ConnectMgr::netTick()
break; break;
case RS_NET_LOOPBACK: case RS_NET_LOOPBACK:
//don't do a shutdown because a client in a computer without network might be usefull for debug. //don't do a shutdown because a client in a computer without local network might be usefull for debug.
//shutdown(); //shutdown();
#ifdef CONN_DEBUG #ifdef CONN_DEBUG
std::cerr << "p3ConnectMgr::netTick() STATUS: RS_NET_LOOPBACK" << std::endl; std::cerr << "p3ConnectMgr::netTick() STATUS: RS_NET_LOOPBACK" << std::endl;
@ -2398,16 +2398,23 @@ bool p3ConnectMgr::retryConnectNotify(std::string id)
bool p3ConnectMgr::setLocalAddress(std::string id, struct sockaddr_in addr) bool p3ConnectMgr::setLocalAddress(std::string id, struct sockaddr_in addr)
{ {
RsStackMutex stack(connMtx); /****** STACK LOCK MUTEX *******/
if (id == mAuthMgr->OwnId()) if (id == mAuthMgr->OwnId())
{ {
ownState.currentlocaladdr = addr; {
IndicateConfigChanged(); /**** INDICATE MSG CONFIG CHANGED! *****/ RsStackMutex stack(connMtx); /****** STACK LOCK MUTEX *******/
return true; ownState.currentlocaladdr = addr;
}
IndicateConfigChanged(); /**** INDICATE MSG CONFIG CHANGED! *****/
if ((ownState.netMode & RS_NET_MODE_ACTUAL) == RS_NET_MODE_EXT ||
(ownState.netMode & RS_NET_MODE_ACTUAL) == RS_NET_MODE_UDP) {
netReset();
}
return true;
} }
/* check if it is a friend */ RsStackMutex stack(connMtx); /****** STACK LOCK MUTEX *******/
/* check if it is a friend */
std::map<std::string, peerConnectState>::iterator it; std::map<std::string, peerConnectState>::iterator it;
if (mFriendList.end() == (it = mFriendList.find(id))) if (mFriendList.end() == (it = mFriendList.find(id)))
{ {
@ -2435,16 +2442,21 @@ bool p3ConnectMgr::setLocalAddress(std::string id, struct sockaddr_in addr)
bool p3ConnectMgr::setExtAddress(std::string id, struct sockaddr_in addr) bool p3ConnectMgr::setExtAddress(std::string id, struct sockaddr_in addr)
{ {
RsStackMutex stack(connMtx); /****** STACK LOCK MUTEX *******/
if (id == mAuthMgr->OwnId()) if (id == mAuthMgr->OwnId())
{ {
ownState.currentserveraddr = addr; {
IndicateConfigChanged(); /**** INDICATE MSG CONFIG CHANGED! *****/ RsStackMutex stack(connMtx); /****** STACK LOCK MUTEX *******/
return true; ownState.currentserveraddr = addr;
}
IndicateConfigChanged(); /**** INDICATE MSG CONFIG CHANGED! *****/
if ((ownState.netMode & RS_NET_MODE_ACTUAL) == RS_NET_MODE_EXT ||
(ownState.netMode & RS_NET_MODE_ACTUAL) == RS_NET_MODE_UDP) {
netReset();
}
return true;
} }
RsStackMutex stack(connMtx); /****** STACK LOCK MUTEX *******/
/* check if it is a friend */ /* check if it is a friend */
std::map<std::string, peerConnectState>::iterator it; std::map<std::string, peerConnectState>::iterator it;
if (mFriendList.end() == (it = mFriendList.find(id))) if (mFriendList.end() == (it = mFriendList.find(id)))
@ -2501,12 +2513,13 @@ bool p3ConnectMgr::setNetworkMode(std::string id, uint32_t netMode)
{ {
uint32_t visState = ownState.visState; uint32_t visState = ownState.visState;
setOwnNetConfig(netMode, visState); setOwnNetConfig(netMode, visState);
if ((netMode & RS_NET_MODE_ACTUAL) != (ownState.netMode & RS_NET_MODE_ACTUAL)) {
netReset();
}
return true; return true;
} }
RsStackMutex stack(connMtx); /****** STACK LOCK MUTEX *******/ RsStackMutex stack(connMtx); /****** STACK LOCK MUTEX *******/
/* check if it is a friend */ /* check if it is a friend */
std::map<std::string, peerConnectState>::iterator it; std::map<std::string, peerConnectState>::iterator it;
if (mFriendList.end() == (it = mFriendList.find(id))) if (mFriendList.end() == (it = mFriendList.find(id)))