mirror of https://github.com/SChernykh/p2pool
Fix: uv_close was called from wrong thread
parent
3e655961e9
commit
fd6b2360aa
|
@ -139,12 +139,6 @@ P2PServer::P2PServer(p2pool* pool)
|
|||
|
||||
P2PServer::~P2PServer()
|
||||
{
|
||||
uv_timer_stop(&m_timer);
|
||||
uv_close(reinterpret_cast<uv_handle_t*>(&m_timer), nullptr);
|
||||
uv_close(reinterpret_cast<uv_handle_t*>(&m_broadcastAsync), nullptr);
|
||||
uv_close(reinterpret_cast<uv_handle_t*>(&m_connectToPeersAsync), nullptr);
|
||||
uv_close(reinterpret_cast<uv_handle_t*>(&m_showPeersAsync), nullptr);
|
||||
|
||||
shutdown_tcp();
|
||||
|
||||
uv_mutex_destroy(&m_rngLock);
|
||||
|
@ -1129,6 +1123,15 @@ P2PServer::P2PClient::P2PClient()
|
|||
{
|
||||
}
|
||||
|
||||
void P2PServer::on_shutdown()
|
||||
{
|
||||
uv_timer_stop(&m_timer);
|
||||
uv_close(reinterpret_cast<uv_handle_t*>(&m_timer), nullptr);
|
||||
uv_close(reinterpret_cast<uv_handle_t*>(&m_broadcastAsync), nullptr);
|
||||
uv_close(reinterpret_cast<uv_handle_t*>(&m_connectToPeersAsync), nullptr);
|
||||
uv_close(reinterpret_cast<uv_handle_t*>(&m_showPeersAsync), nullptr);
|
||||
}
|
||||
|
||||
P2PServer::P2PClient::~P2PClient()
|
||||
{
|
||||
}
|
||||
|
|
|
@ -234,6 +234,8 @@ private:
|
|||
|
||||
static void on_show_peers(uv_async_t* handle) { reinterpret_cast<P2PServer*>(handle->data)->show_peers(); }
|
||||
void show_peers();
|
||||
|
||||
void on_shutdown() override;
|
||||
};
|
||||
|
||||
} // namespace p2pool
|
||||
|
|
|
@ -84,8 +84,6 @@ StratumServer::StratumServer(p2pool* pool)
|
|||
|
||||
StratumServer::~StratumServer()
|
||||
{
|
||||
uv_close(reinterpret_cast<uv_handle_t*>(&m_blobsAsync), nullptr);
|
||||
|
||||
shutdown_tcp();
|
||||
|
||||
uv_mutex_destroy(&m_blobsQueueLock);
|
||||
|
@ -935,6 +933,11 @@ void StratumServer::on_after_share_found(uv_work_t* req, int /*status*/)
|
|||
}
|
||||
}
|
||||
|
||||
void StratumServer::on_shutdown()
|
||||
{
|
||||
uv_close(reinterpret_cast<uv_handle_t*>(&m_blobsAsync), nullptr);
|
||||
}
|
||||
|
||||
StratumServer::StratumClient::StratumClient()
|
||||
: m_rpcId(0)
|
||||
, m_perConnectionJobId(0)
|
||||
|
|
|
@ -179,6 +179,8 @@ private:
|
|||
|
||||
void update_hashrate_data(uint64_t hashes, uint64_t timestamp);
|
||||
void api_update_local_stats(uint64_t timestamp);
|
||||
|
||||
void on_shutdown() override;
|
||||
};
|
||||
|
||||
} // namespace p2pool
|
||||
|
|
|
@ -181,10 +181,13 @@ protected:
|
|||
uv_async_t m_dropConnectionsAsync;
|
||||
static void on_drop_connections(uv_async_t* async) { reinterpret_cast<TCPServer*>(async->data)->close_sockets(false); }
|
||||
|
||||
virtual void on_shutdown() = 0;
|
||||
|
||||
uv_async_t m_shutdownAsync;
|
||||
static void on_shutdown(uv_async_t* async)
|
||||
{
|
||||
TCPServer* server = reinterpret_cast<TCPServer*>(async->data);
|
||||
server->on_shutdown();
|
||||
server->close_sockets(true);
|
||||
|
||||
uv_close(reinterpret_cast<uv_handle_t*>(&server->m_dropConnectionsAsync), nullptr);
|
||||
|
|
Loading…
Reference in New Issue