NULL dereference on still-initializing node bug fix in status query commands, and doc updates.

This commit is contained in:
Adam Ierymenko 2014-10-28 14:17:39 -07:00
parent f873881a0d
commit 3d85a615fb
4 changed files with 77 additions and 19 deletions

View file

@ -702,9 +702,9 @@ bool Node::online()
throw()
{
_NodeImpl *impl = (_NodeImpl *)_impl;
if (!impl->running)
return false;
RuntimeEnvironment *RR = (RuntimeEnvironment *)&(impl->renv);
if ((!RR)||(!RR->initialized))
return false;
uint64_t now = Utils::now();
uint64_t since = RR->timeOfLastResynchronize;
std::vector< SharedPtr<Peer> > snp(RR->topology->supernodePeers());
@ -753,7 +753,8 @@ void Node::join(uint64_t nwid)
{
_NodeImpl *impl = (_NodeImpl *)_impl;
RuntimeEnvironment *RR = (RuntimeEnvironment *)&(impl->renv);
RR->nc->join(nwid);
if ((RR)&&(RR->initialized))
RR->nc->join(nwid);
}
void Node::leave(uint64_t nwid)
@ -761,7 +762,8 @@ void Node::leave(uint64_t nwid)
{
_NodeImpl *impl = (_NodeImpl *)_impl;
RuntimeEnvironment *RR = (RuntimeEnvironment *)&(impl->renv);
RR->nc->leave(nwid);
if ((RR)&&(RR->initialized))
RR->nc->leave(nwid);
}
struct GatherPeerStatistics
@ -785,6 +787,9 @@ void Node::status(ZT1_Node_Status *status)
memset(status,0,sizeof(ZT1_Node_Status));
if ((!RR)||(!RR->initialized))
return;
Utils::scopy(status->publicIdentity,sizeof(status->publicIdentity),RR->identity.toString(false).c_str());
RR->identity.address().toString(status->address,sizeof(status->address));
status->rawAddress = RR->identity.address().toInt();
@ -807,6 +812,7 @@ void Node::status(ZT1_Node_Status *status)
status->online = online();
status->running = impl->running;
status->initialized = true;
}
struct CollectPeersAndPaths
@ -824,6 +830,9 @@ ZT1_Node_PeerList *Node::listPeers()
_NodeImpl *impl = (_NodeImpl *)_impl;
RuntimeEnvironment *RR = (RuntimeEnvironment *)&(impl->renv);
if ((!RR)||(!RR->initialized))
return (ZT1_Node_PeerList *)0;
CollectPeersAndPaths pp;
RR->topology->eachPeer<CollectPeersAndPaths &>(pp);
std::sort(pp.data.begin(),pp.data.end(),SortPeersAndPathsInAscendingAddressOrder());
@ -910,6 +919,9 @@ ZT1_Node_Network *Node::getNetworkStatus(uint64_t nwid)
_NodeImpl *impl = (_NodeImpl *)_impl;
RuntimeEnvironment *RR = (RuntimeEnvironment *)&(impl->renv);
if ((!RR)||(!RR->initialized))
return (ZT1_Node_Network *)0;
SharedPtr<Network> network(RR->nc->network(nwid));
if (!network)
return (ZT1_Node_Network *)0;
@ -950,6 +962,9 @@ ZT1_Node_NetworkList *Node::listNetworks()
_NodeImpl *impl = (_NodeImpl *)_impl;
RuntimeEnvironment *RR = (RuntimeEnvironment *)&(impl->renv);
if ((!RR)||(!RR->initialized))
return (ZT1_Node_NetworkList *)0;
std::vector< SharedPtr<Network> > networks(RR->nc->networks());
std::vector< SharedPtr<NetworkConfig> > nconfs(networks.size());
std::vector< std::set<InetAddress> > ipsv(networks.size());