Simple-Web-Server icon indicating copy to clipboard operation
Simple-Web-Server copied to clipboard

glaceful close ssl socket

Open lxlenovostar opened this issue 7 years ago • 3 comments

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.

lxlenovostar avatar Feb 05 '18 12:02 lxlenovostar

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.

eidheim avatar Feb 05 '18 13:02 eidheim

Although, thank you for bringing this up. I'll add a couple of labels to this issue.

eidheim avatar Feb 05 '18 13:02 eidheim

@eidheim In a rare case, If I don't add mutex before shutdown/close, SIGSEGV happen. Why you choose use mutex before shutdown/close?

lxlenovostar avatar Feb 08 '18 11:02 lxlenovostar