Simple-Web-Server
Simple-Web-Server copied to clipboard
glaceful close ssl socket
Hi: @eidheim
void close() noexcept {
error_code ec;
std::unique_lock<std::mutex> lock(socket_close_mutex); // The following operations seems to be needed to run sequentially
socket->lowest_layer().shutdown(asio::ip::tcp::socket::shutdown_both, ec);
socket->lowest_layer().close(ec);
}
In this way, we directly close tcp socket, why we not close SSL socket first in HTTPS server?
Thank you.
Last time I studied this I came to the conclusion that calling ssl::stream::shutdown was not needed. Though I might be wrong! By the way, ssl::stream does not have a close
-member function.
Although, thank you for bringing this up. I'll add a couple of labels to this issue.
@eidheim In a rare case, If I don't add mutex before shutdown/close, SIGSEGV happen. Why you choose use mutex before shutdown/close?