From 8d242e0112c7f9072600a48366ebbd6ce7b5c727 Mon Sep 17 00:00:00 2001 From: Determinant Date: Fri, 28 Jun 2019 22:49:03 -0400 Subject: fix data race in timers --- src/conn.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/conn.cpp b/src/conn.cpp index e01690d..b6c6c71 100644 --- a/src/conn.cpp +++ b/src/conn.cpp @@ -248,8 +248,8 @@ void ConnPool::Conn::stop() { { if (worker) worker->unfeed(); if (tls) tls->shutdown(); - ev_connect.del(); - ev_socket.del(); + ev_socket.clear(); + ev_connect.clear(); send_buffer.get_queue().unreg_handler(); mode = ConnMode::DEAD; } @@ -419,9 +419,8 @@ void ConnPool::del_conn(const conn_t &conn) { void ConnPool::release_conn(const conn_t &conn) { /* inform the upper layer the connection will be destroyed */ on_teardown(conn); - conn->ev_connect.clear(); - conn->ev_socket.clear(); ::close(conn->fd); + std::atomic_thread_fence(std::memory_order_release); } ConnPool::conn_t ConnPool::add_conn(const conn_t &conn) { -- cgit v1.2.3-70-g09d2