From 65f7c078663da387fd2cee8ab401c7ef66081138 Mon Sep 17 00:00:00 2001 From: Determinant Date: Thu, 20 Jun 2019 19:17:11 -0400 Subject: add TLS benchmark --- src/conn.cpp | 16 ++++++++++------ src/network.cpp | 2 +- src/util.cpp | 2 ++ 3 files changed, 13 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/conn.cpp b/src/conn.cpp index 60d5835..535803b 100644 --- a/src/conn.cpp +++ b/src/conn.cpp @@ -211,13 +211,18 @@ void ConnPool::Conn::_recv_data_tls(const ConnPool::conn_t &conn, int fd, int ev conn->on_read(); } -void ConnPool::Conn::_send_data_tls_handshake(const ConnPool::conn_t &conn, int, int) { +void ConnPool::Conn::_send_data_tls_handshake(const ConnPool::conn_t &conn, int fd, int events) { + conn->ready_send = true; + _recv_data_tls_handshake(conn, fd, events); +} + +void ConnPool::Conn::_recv_data_tls_handshake(const ConnPool::conn_t &conn, int, int) { int ret; if (conn->tls->do_handshake(ret)) { /* finishing TLS handshake */ conn->send_data_func = _send_data_tls; - conn->recv_data_func = _recv_data_tls; + conn->recv_data_func = _recv_data_dummy; conn->peer_cert = new X509(conn->tls->get_peer_cert()); conn->cpool->update_conn(conn, true); } @@ -229,9 +234,8 @@ void ConnPool::Conn::_send_data_tls_handshake(const ConnPool::conn_t &conn, int, } } -void ConnPool::Conn::_recv_data_tls_handshake(const ConnPool::conn_t &conn, int fd, int events) { - conn->ready_send = true; - _send_data_tls_handshake(conn, fd, events); + +void ConnPool::Conn::_recv_data_dummy(const ConnPool::conn_t &, int, int) { } /****/ @@ -239,6 +243,7 @@ void ConnPool::Conn::stop() { if (mode != ConnMode::DEAD) { if (worker) worker->unfeed(); + if (tls) tls->shutdown(); ev_connect.clear(); ev_socket.clear(); send_buffer.get_queue().unreg_handler(); @@ -290,7 +295,6 @@ void ConnPool::accept_client(int fd, int) { conn->send_buffer.set_capacity(queue_capacity); conn->seg_buff_size = seg_buff_size; conn->fd = client_fd; - conn->worker = nullptr; conn->cpool = this; conn->mode = Conn::PASSIVE; conn->addr = addr; diff --git a/src/network.cpp b/src/network.cpp index b8d058a..4067531 100644 --- a/src/network.cpp +++ b/src/network.cpp @@ -96,7 +96,7 @@ void msgnetwork_reg_conn_handler(msgnetwork_t *self, void *userdata) { self->reg_conn_handler([=](const ConnPool::conn_t &_conn, bool connected) { auto conn = salticidae::static_pointer_cast(_conn); - cb(&conn, connected, userdata); + return cb(&conn, connected, userdata); }); } diff --git a/src/util.cpp b/src/util.cpp index 66bcd12..1493b20 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -53,6 +53,8 @@ const char *SALTICIDAE_ERROR_STRINGS[] = { "tls generic error", "x509 cert error", "EVP_PKEY error", + "tls key does not match the cert", + "tls fail to get peer cert", "unknown error" }; -- cgit v1.2.3-70-g09d2