P2PServer: removed an unnecessary lock

pull/226/head
SChernykh 1 year ago
parent 3f66975e1b
commit 7eec4d742c

@ -86,7 +86,6 @@ P2PServer::P2PServer(p2pool* pool)
set_max_outgoing_peers(params.m_maxOutgoingPeers);
set_max_incoming_peers(params.m_maxIncomingPeers);
uv_mutex_init_checked(&m_rngLock);
uv_mutex_init_checked(&m_blockLock);
uv_mutex_init_checked(&m_peerListLock);
uv_mutex_init_checked(&m_broadcastLock);
@ -142,7 +141,6 @@ P2PServer::~P2PServer()
{
shutdown_tcp();
uv_mutex_destroy(&m_rngLock);
uv_mutex_destroy(&m_blockLock);
uv_mutex_destroy(&m_peerListLock);
uv_mutex_destroy(&m_broadcastLock);
@ -365,10 +363,9 @@ void P2PServer::update_peer_connections()
void P2PServer::update_peer_list()
{
const uint64_t cur_time = seconds_since_epoch();
MutexLock lock(m_clientsListLock);
const uint64_t cur_time = seconds_since_epoch();
for (P2PClient* client = static_cast<P2PClient*>(m_connectedClientsList->m_next); client != m_connectedClientsList; client = static_cast<P2PClient*>(client->m_next)) {
if (client->is_good() && (cur_time >= client->m_nextOutgoingPeerListRequest)) {
send_peer_list_request(client, cur_time);
@ -934,7 +931,9 @@ void P2PServer::on_broadcast()
uint64_t P2PServer::get_random64()
{
MutexLock lock(m_rngLock);
if (!server_event_loop_thread) {
LOGERR(1, "get_random64() was called from another thread, this is not thread safe");
}
return m_rng();
}

@ -189,7 +189,6 @@ private:
void remove_peer_from_list(P2PClient* client);
void remove_peer_from_list(const raw_ip& ip);
uv_mutex_t m_rngLock;
std::mt19937_64 m_rng;
uv_mutex_t m_blockLock;

Loading…
Cancel
Save