commit - 4e9d56a43bc5ecd2a5833b12f79bc8aa10f8df4f
commit + 4dc73fe178293aa9744ad4f7fd0ff1c93a306db7
blob - 419f406db1ab70fb3bd5a626dfffd29d01cb498d
blob + 3d747c03afa11b9d1acf05ac00a5bb5276c21b51
--- vostok/transport.cc
+++ vostok/transport.cc
}
m_ctx.reset(ctx);
- m_is_accepted = true;
}
AcceptedClient::~AcceptedClient()
{
- if (m_is_accepted)
+ if (is_accepted())
{
if (tls_close(get_ctx()) == -1)
error::occurred("TLS close", PrintIfError{tls_error(get_ctx())});
blob - f72eefdb1d87f652891285c851316e9dd16ef3d6
blob + a26593303a364b07a7f3e9ca5b710e398fc23ef6
--- vostok/transport.h
+++ vostok/transport.h
};
-/** Accept new client */
+/** Accept new client: socket and TLS context */
class AcceptedClient
{
public:
+ /** Check success by is_accepted() calling */
AcceptedClient(int server_socket, struct tls *server_ctx);
- ~AcceptedClient(); // Send TLS close_notify (if accepted)
- bool is_accepted() const { return m_is_accepted; }
+ /** Send Send TLS `close_notify` (if accepted */
+ ~AcceptedClient();
+ bool is_accepted() const { return !!m_fd && m_ctx.get(); }
+
struct tls *get_ctx() const { return m_ctx.get(); }
int get_fd() const { return m_fd.get(); }
private:
UniqueFd m_fd;
ContextPtr m_ctx;
- bool m_is_accepted{false};
};