aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDeterminant <[email protected]>2019-06-20 19:17:11 -0400
committerDeterminant <[email protected]>2019-06-20 19:17:11 -0400
commit65f7c078663da387fd2cee8ab401c7ef66081138 (patch)
tree121e0249651e7caa3dcbd09df639879af5dd46c9 /src
parent4f41e23016dc316334e7d6cc8765bdf334b96f3e (diff)
add TLS benchmark
Diffstat (limited to 'src')
-rw-r--r--src/conn.cpp16
-rw-r--r--src/network.cpp2
-rw-r--r--src/util.cpp2
3 files changed, 13 insertions, 7 deletions
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<msgnetwork_t::Conn>(_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"
};