diff options
author | Determinant <[email protected]> | 2018-11-16 15:50:22 -0500 |
---|---|---|
committer | Determinant <[email protected]> | 2018-11-16 15:50:22 -0500 |
commit | b84497791d19d90793c758c7d8e88e57c9d142e6 (patch) | |
tree | 3244f3312d45bb08ef75f22e9ebd1125296a0a61 /src | |
parent | d6e9a45639e688cd4d745f610401f74f8ee02011 (diff) |
WIP: stress test; fix bugs
Diffstat (limited to 'src')
-rw-r--r-- | src/conn.cpp | 17 |
1 files changed, 10 insertions, 7 deletions
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 */ } } |