diff options
-rw-r--r-- | include/salticidae/conn.h | 1 | ||||
-rw-r--r-- | include/salticidae/network.h | 4 | ||||
-rw-r--r-- | src/conn.cpp | 1 | ||||
-rw-r--r-- | src/network.cpp | 18 |
4 files changed, 16 insertions, 8 deletions
diff --git a/include/salticidae/conn.h b/include/salticidae/conn.h index a1b5633..a345845 100644 --- a/include/salticidae/conn.h +++ b/include/salticidae/conn.h @@ -114,7 +114,6 @@ class ConnPool { Conn(Conn &&other) = delete; virtual ~Conn() { - //std::atomic_thread_fence(std::memory_order_acquire); SALTICIDAE_LOG_INFO("destroyed %s", std::string(*this).c_str()); } diff --git a/include/salticidae/network.h b/include/salticidae/network.h index 8372b9a..1f21c92 100644 --- a/include/salticidae/network.h +++ b/include/salticidae/network.h @@ -1264,7 +1264,7 @@ peernetwork_conn_t *peernetwork_conn_new_from_msgnetwork_conn_unsafe(const msgne peernetwork_conn_t *peernetwork_conn_copy(const peernetwork_conn_t *self); netaddr_t *peernetwork_conn_get_peer_addr(const peernetwork_conn_t *self); void peernetwork_conn_free(const peernetwork_conn_t *self); -void peernetwork_send_msg(peernetwork_t *self, const msg_t * msg, const netaddr_t *addr); +bool peernetwork_send_msg(peernetwork_t *self, const msg_t * msg, const netaddr_t *addr); void peernetwork_send_msg_deferred_by_move(peernetwork_t *self, msg_t * _moved_msg, const netaddr_t *addr); void peernetwork_multicast_msg_by_move(peernetwork_t *self, msg_t *_moved_msg, const netaddr_array_t *addrs); void peernetwork_listen(peernetwork_t *self, const netaddr_t *listen_addr, SalticidaeCError *err); @@ -1285,7 +1285,7 @@ msgnetwork_conn_t *msgnetwork_conn_new_from_clientnetwork_conn(const clientnetwo clientnetwork_conn_t *clientnetwork_conn_new_from_msgnetwork_conn_unsafe(const msgnetwork_conn_t *conn); clientnetwork_conn_t *clientnetwork_conn_copy(const clientnetwork_conn_t *self); void clientnetwork_conn_free(const clientnetwork_conn_t *self); -void clientnetwork_send_msg(clientnetwork_t *self, const msg_t * msg, const netaddr_t *addr); +bool clientnetwork_send_msg(clientnetwork_t *self, const msg_t * msg, const netaddr_t *addr); void clientnetwork_send_msg_deferred_by_move(clientnetwork_t *self, msg_t * _moved_msg, const netaddr_t *addr); #ifdef __cplusplus diff --git a/src/conn.cpp b/src/conn.cpp index f26c480..abea7ac 100644 --- a/src/conn.cpp +++ b/src/conn.cpp @@ -408,7 +408,6 @@ void ConnPool::del_conn(const conn_t &conn) { pool.erase(it); update_conn(conn, false); release_conn(conn); - //std::atomic_thread_fence(std::memory_order_release); } void ConnPool::release_conn(const conn_t &conn) { diff --git a/src/network.cpp b/src/network.cpp index 5b0018c..e604eaa 100644 --- a/src/network.cpp +++ b/src/network.cpp @@ -235,8 +235,13 @@ netaddr_t *peernetwork_conn_get_peer_addr(const peernetwork_conn_t *self) { void peernetwork_conn_free(const peernetwork_conn_t *self) { delete self; } -void peernetwork_send_msg(peernetwork_t *self, const msg_t * msg, const netaddr_t *addr) { - self->_send_msg(*msg, *addr); +bool peernetwork_send_msg(peernetwork_t *self, const msg_t * msg, const netaddr_t *addr) { + try { + self->_send_msg(*msg, *addr); + return true; + } catch (...) { + return false; + } } void peernetwork_send_msg_deferred_by_move(peernetwork_t *self, @@ -300,8 +305,13 @@ clientnetwork_conn_t *clientnetwork_conn_copy(const clientnetwork_conn_t *self) void clientnetwork_conn_free(const clientnetwork_conn_t *self) { delete self; } -void clientnetwork_send_msg(clientnetwork_t *self, const msg_t * msg, const netaddr_t *addr) { - self->_send_msg(*msg, *addr); +bool clientnetwork_send_msg(clientnetwork_t *self, const msg_t * msg, const netaddr_t *addr) { + try { + self->_send_msg(*msg, *addr); + return true; + } catch (...) { + return false; + } } void clientnetwork_send_msg_deferred_by_move(clientnetwork_t *self, msg_t *_moved_msg, const netaddr_t *addr) { |