Skip to content
This repository has been archived by the owner on Jun 12, 2018. It is now read-only.

glaceful close ssl socket #207

Open
lxlenovostar opened this issue Feb 5, 2018 · 3 comments
Open

glaceful close ssl socket #207

lxlenovostar opened this issue Feb 5, 2018 · 3 comments

Comments

@lxlenovostar
Copy link

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.

@eidheim
Copy link
Owner

eidheim commented Feb 5, 2018

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
Copy link
Owner

eidheim commented Feb 5, 2018

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

@lxlenovostar
Copy link
Author

lxlenovostar commented Feb 8, 2018

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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants