From bb1c884a2f466cccbc4e719f8ec021e627f2dda3 Mon Sep 17 00:00:00 2001 From: Determinant Date: Thu, 20 Feb 2020 11:56:48 -0500 Subject: fix the potential data race in known_peers --- src/network.cpp | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/network.cpp b/src/network.cpp index 286c3ef..4182a41 100644 --- a/src/network.cpp +++ b/src/network.cpp @@ -227,27 +227,35 @@ peernetwork_t *peernetwork_new(const eventcontext_t *ec, const peernetwork_confi void peernetwork_free(const peernetwork_t *self) { delete self; } -int32_t peernetwork_add_peer(peernetwork_t *self, const peerid_t *pid) { - return self->add_peer(*pid); +int32_t peernetwork_add_peer(peernetwork_t *self, const peerid_t *peer) { + return self->add_peer(*peer); } -int32_t peernetwork_del_peer(peernetwork_t *self, const peerid_t *pid) { - return self->del_peer(*pid); +int32_t peernetwork_del_peer(peernetwork_t *self, const peerid_t *peer) { + return self->del_peer(*peer); } -bool peernetwork_has_peer(const peernetwork_t *self, const peerid_t *pid) { - return self->has_peer(*pid); +int32_t peernetwork_conn_peer(peernetwork_t *self, const peerid_t *peer, ssize_t ntry, double retry_delay) { + return self->conn_peer(*peer, ntry, retry_delay); +} + +bool peernetwork_has_peer(const peernetwork_t *self, const peerid_t *peer) { + return self->has_peer(*peer); } const peernetwork_conn_t *peernetwork_get_peer_conn(const peernetwork_t *self, - const peerid_t *pid, + const peerid_t *peer, SalticidaeCError *cerror) { SALTICIDAE_CERROR_TRY(cerror) - return new peernetwork_conn_t(self->get_peer_conn(*pid)); + return new peernetwork_conn_t(self->get_peer_conn(*peer)); SALTICIDAE_CERROR_CATCH(cerror) return nullptr; } +int32_t peernetwork_set_peer_addr(peernetwork_t *self, const peerid_t *peer, const netaddr_t *addr) { + return self->set_peer_addr(*peer, *addr); +} + msgnetwork_t *peernetwork_as_msgnetwork(peernetwork_t *self) { return self; } peernetwork_t *msgnetwork_as_peernetwork_unsafe(msgnetwork_t *self) { -- cgit v1.2.3-70-g09d2