From 9169b6c99902f546fe98e32d24768f4798d3c772 Mon Sep 17 00:00:00 2001 From: Adam Ierymenko Date: Tue, 17 Nov 2015 09:56:19 -0800 Subject: 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. --- node/Topology.cpp | 43 +++++++++++++++++++++++++------------------ 1 file changed, 25 insertions(+), 18 deletions(-) (limited to 'node') 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 pbuf; - std::string all; - - Address *a = (Address *)0; - SharedPtr *p = (SharedPtr *)0; - Hashtable< Address,SharedPtr >::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 *pbuf = 0; + try { + pbuf = new Buffer(); + std::string all; + + Address *a = (Address *)0; + SharedPtr *p = (SharedPtr *)0; + Hashtable< Address,SharedPtr >::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 Topology::addPeer(const SharedPtr &peer) -- cgit v1.2.3