Browse Source

Prevent infinite sleep on connect. Write settings before shutdown of web3.

cl-refactor
subtly 10 years ago
parent
commit
a153d078bc
  1. 2
      alethzero/MainWin.cpp
  2. 6
      libp2p/Host.cpp
  3. 4
      libp2p/NodeTable.cpp

2
alethzero/MainWin.cpp

@ -211,11 +211,11 @@ Main::Main(QWidget *parent) :
Main::~Main()
{
writeSettings();
// Must do this here since otherwise m_ethereum'll be deleted (and therefore clearWatches() called by the destructor)
// *after* the client is dead.
m_qweb->clientDieing();
g_logPost = simpleDebugOut;
writeSettings();
}
void Main::on_newIdentity_triggered()

6
libp2p/Host.cpp

@ -428,8 +428,9 @@ void Host::addNode(NodeId const& _node, std::string const& _addr, unsigned short
void Host::connect(std::shared_ptr<Peer> const& _p)
{
while (isWorking() && !m_run)
this_thread::sleep_for(chrono::milliseconds(50));
for (unsigned i = 0; i < 40; i++)
if (isWorking() && !m_run)
this_thread::sleep_for(chrono::milliseconds(50));
if (!m_run)
return;
@ -442,6 +443,7 @@ void Host::connect(std::shared_ptr<Peer> const& _p)
if (!m_nodeTable->haveNode(_p->id))
{
clog(NetWarn) << "Aborted connect. Node not in node table.";
m_nodeTable->addNode(*_p.get());
return;
}

4
libp2p/NodeTable.cpp

@ -65,7 +65,7 @@ void NodeTable::processEvents()
shared_ptr<NodeEntry> NodeTable::addNode(Public const& _pubk, bi::udp::endpoint const& _udp, bi::tcp::endpoint const& _tcp)
{
auto node = Node(_pubk, NodeIPEndpoint(_udp, _tcp));
return move(addNode(node));
return addNode(node);
}
shared_ptr<NodeEntry> NodeTable::addNode(Node const& _node)
@ -101,7 +101,7 @@ shared_ptr<NodeEntry> NodeTable::addNode(Node const& _node)
if (m_nodeEventHandler)
m_nodeEventHandler->appendEvent(_node.id, NodeEntryAdded);
return move(ret);
return ret;
}
void NodeTable::discover()

Loading…
Cancel
Save