summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdam Ierymenko <adam.ierymenko@zerotier.com>2015-11-17 09:56:19 -0800
committerAdam Ierymenko <adam.ierymenko@zerotier.com>2015-11-17 09:56:19 -0800
commit9169b6c99902f546fe98e32d24768f4798d3c772 (patch)
tree61b0d1c900e750feef639734c9bbe9eccbe0f2dd
parent48745eca571a87558a4a0a3741ffa106a6ae14bf (diff)
downloadinfinitytier-9169b6c99902f546fe98e32d24768f4798d3c772.tar.gz
infinitytier-9169b6c99902f546fe98e32d24768f4798d3c772.zip
Fix crash on exit in Windows (does not affect other OSes) and revert debugging tweak in Windows version that prevented service from starting after real install.
-rw-r--r--node/Topology.cpp43
-rw-r--r--one.cpp2
2 files changed, 26 insertions, 19 deletions
diff --git a/node/Topology.cpp b/node/Topology.cpp
index a3faaf23..c7de22a8 100644
--- a/node/Topology.cpp
+++ b/node/Topology.cpp
@@ -96,27 +96,34 @@ Topology::Topology(const RuntimeEnvironment *renv) :
Topology::~Topology()
{
- Buffer<ZT_PEER_SUGGESTED_SERIALIZATION_BUFFER_SIZE> pbuf;
- std::string all;
-
- Address *a = (Address *)0;
- SharedPtr<Peer> *p = (SharedPtr<Peer> *)0;
- Hashtable< Address,SharedPtr<Peer> >::Iterator i(_peers);
- while (i.next(a,p)) {
- if (std::find(_rootAddresses.begin(),_rootAddresses.end(),*a) == _rootAddresses.end()) {
- pbuf.clear();
- try {
- (*p)->serialize(pbuf);
+ Buffer<ZT_PEER_SUGGESTED_SERIALIZATION_BUFFER_SIZE> *pbuf = 0;
+ try {
+ pbuf = new Buffer<ZT_PEER_SUGGESTED_SERIALIZATION_BUFFER_SIZE>();
+ std::string all;
+
+ Address *a = (Address *)0;
+ SharedPtr<Peer> *p = (SharedPtr<Peer> *)0;
+ Hashtable< Address,SharedPtr<Peer> >::Iterator i(_peers);
+ while (i.next(a,p)) {
+ if (std::find(_rootAddresses.begin(),_rootAddresses.end(),*a) == _rootAddresses.end()) {
+ pbuf->clear();
try {
- all.append((const char *)pbuf.data(),pbuf.size());
- } catch ( ... ) {
- return; // out of memory? just skip
- }
- } catch ( ... ) {} // peer too big? shouldn't happen, but it so skip
+ (*p)->serialize(*pbuf);
+ try {
+ all.append((const char *)pbuf->data(),pbuf->size());
+ } catch ( ... ) {
+ return; // out of memory? just skip
+ }
+ } catch ( ... ) {} // peer too big? shouldn't happen, but it so skip
+ }
}
- }
- RR->node->dataStorePut("peers.save",all,true);
+ RR->node->dataStorePut("peers.save",all,true);
+
+ delete pbuf;
+ } catch ( ... ) {
+ delete pbuf;
+ }
}
SharedPtr<Peer> Topology::addPeer(const SharedPtr<Peer> &peer)
diff --git a/one.cpp b/one.cpp
index 11bcc11e..685034df 100644
--- a/one.cpp
+++ b/one.cpp
@@ -966,7 +966,7 @@ int main(int argc,char **argv)
#ifdef ZT_WIN_RUN_IN_CONSOLE
bool winRunFromCommandLine = true;
#else
- bool winRunFromCommandLine = true;
+ bool winRunFromCommandLine = false;
#endif
#endif // __WINDOWS__