h2load: Reuse SSL/TLS session

This commit is contained in:
Tatsuhiro Tsujikawa 2015-09-28 23:59:42 +09:00
parent ff87bf7584
commit 55075516c9
1 changed files with 15 additions and 5 deletions

View File

@ -244,7 +244,13 @@ Client::Client(Worker *worker, size_t req_todo)
request_timeout_watcher.data = this; request_timeout_watcher.data = this;
} }
Client::~Client() { disconnect(); } Client::~Client() {
disconnect();
if (ssl) {
SSL_free(ssl);
}
}
int Client::do_read() { return readfn(*this); } int Client::do_read() { return readfn(*this); }
int Client::do_write() { return writefn(*this); } int Client::do_write() { return writefn(*this); }
@ -255,7 +261,9 @@ int Client::make_socket(addrinfo *addr) {
return -1; return -1;
} }
if (config.scheme == "https") { if (config.scheme == "https") {
ssl = SSL_new(worker->ssl_ctx); if (!ssl) {
ssl = SSL_new(worker->ssl_ctx);
}
auto config = worker->config; auto config = worker->config;
@ -362,9 +370,11 @@ void Client::disconnect() {
if (ssl) { if (ssl) {
SSL_set_shutdown(ssl, SSL_RECEIVED_SHUTDOWN); SSL_set_shutdown(ssl, SSL_RECEIVED_SHUTDOWN);
ERR_clear_error(); ERR_clear_error();
SSL_shutdown(ssl);
SSL_free(ssl); if (SSL_shutdown(ssl) != 1) {
ssl = nullptr; SSL_free(ssl);
ssl = nullptr;
}
} }
if (fd != -1) { if (fd != -1) {
shutdown(fd, SHUT_WR); shutdown(fd, SHUT_WR);