From 3707146f42ccc066edf214cc77118f91b687e47b Mon Sep 17 00:00:00 2001 From: Determinant Date: Fri, 21 Feb 2020 18:23:40 -0500 Subject: adjust on_setup and on_teardown and fix minor bugs --- src/conn.cpp | 25 +++++++++++++------------ src/util.cpp | 1 + 2 files changed, 14 insertions(+), 12 deletions(-) (limited to 'src') diff --git a/src/conn.cpp b/src/conn.cpp index a5d60a7..af15276 100644 --- a/src/conn.cpp +++ b/src/conn.cpp @@ -251,9 +251,15 @@ void ConnPool::Conn::_recv_data_tls_handshake(const conn_t &conn, int, int) { conn->peer_cert = new X509(conn->tls->get_peer_cert()); conn->worker->enable_send_buffer(conn, conn->fd); auto cpool = conn->cpool; + cpool->on_worker_setup(conn); cpool->disp_tcall->async_call([cpool, conn](ThreadCall::Handle &) { - cpool->on_setup(conn); - cpool->update_conn(conn, true); + try { + cpool->on_dispatcher_setup(conn); + cpool->update_conn(conn, true); + } catch (...) { + cpool->recoverable_error(std::current_exception(), -1); + cpool->disp_terminate(conn); + } }); } else @@ -266,17 +272,11 @@ void ConnPool::Conn::_recv_data_tls_handshake(const conn_t &conn, int, int) { void ConnPool::Conn::_recv_data_dummy(const conn_t &, int, int) {} -void ConnPool::Conn::stop() { - if (worker) worker->unfeed(); - if (tls) tls->shutdown(); - ev_socket.clear(); - send_buffer.get_queue().unreg_handler(); -} - void ConnPool::worker_terminate(const conn_t &conn) { conn->worker->get_tcall()->async_call([this, conn](ThreadCall::Handle &) { if (!conn->set_terminated()) return; - conn->stop(); + on_worker_teardown(conn); + //conn->stop(); disp_tcall->async_call([this, conn](ThreadCall::Handle &) { del_conn(conn); }); @@ -292,7 +292,8 @@ void ConnPool::disp_terminate(const conn_t &conn) { else disp_tcall->async_call([this, conn](ThreadCall::Handle &) { if (!conn->set_terminated()) return; - conn->stop(); + on_worker_teardown(conn); + //conn->stop(); del_conn(conn); }); } @@ -440,7 +441,7 @@ 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 */ conn->ev_connect.clear(); - on_teardown(conn); + on_dispatcher_teardown(conn); ::close(conn->fd); } diff --git a/src/util.cpp b/src/util.cpp index 8ca01aa..01f6b06 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -43,6 +43,7 @@ const char *SALTICIDAE_ERROR_STRINGS[] = { "peer already exists", "peer does not exist", "peer is not ready", + "peer id does not match the record", "client does not exist", "invalid NetAddr format", "invalid OptVal format", -- cgit v1.2.3-70-g09d2