From b84497791d19d90793c758c7d8e88e57c9d142e6 Mon Sep 17 00:00:00 2001 From: Determinant Date: Fri, 16 Nov 2018 15:50:22 -0500 Subject: WIP: stress test; fix bugs --- src/conn.cpp | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/conn.cpp b/src/conn.cpp index 841002f..ca13619 100644 --- a/src/conn.cpp +++ b/src/conn.cpp @@ -119,13 +119,15 @@ void ConnPool::Conn::recv_data(int fd, int events) { } void ConnPool::Conn::stop() { - if (!self_ref) return; - if (worker) worker->unfeed(); - ev_connect.clear(); - ev_socket.clear(); - send_buffer.get_queue().unreg_handler(); - ::close(fd); - self_ref = nullptr; /* remove the self-cycle */ + if (mode != ConnMode::DEAD) + { + if (worker) worker->unfeed(); + ev_connect.clear(); + ev_socket.clear(); + send_buffer.get_queue().unreg_handler(); + ::close(fd); + mode = ConnMode::DEAD; + } } void ConnPool::Conn::worker_terminate() { @@ -280,6 +282,7 @@ void ConnPool::remove_conn(int fd) { /* inform the upper layer the connection will be destroyed */ conn->on_teardown(); update_conn(conn, false); + conn->self_ref = nullptr; /* remove the self-cycle */ } } -- cgit v1.2.3-70-g09d2