| 808 | }; |
| 809 | |
| 810 | void action(Handshake& h) { |
| 811 | try { |
| 812 | h.socket.next_layer().non_blocking(false, h.err); |
| 813 | if (!h.err.failed()) { |
| 814 | h.socket.handshake(h.type, h.err); |
| 815 | } |
| 816 | if (!h.err.failed()) { |
| 817 | h.socket.next_layer().non_blocking(true, h.err); |
| 818 | } |
| 819 | if (h.err.failed()) { |
| 820 | TraceEvent(SevWarn, |
| 821 | h.type == ssl_socket::handshake_type::client ? "N2_ConnectHandshakeError" |
| 822 | : "N2_AcceptHandshakeError") |
| 823 | .detail("ErrorCode", h.err.value()) |
| 824 | .detail("ErrorMsg", h.err.message().c_str()) |
| 825 | .detail("BackgroundThread", true); |
| 826 | h.done.sendError(connection_failed()); |
| 827 | } else { |
| 828 | h.done.send(Void()); |
| 829 | } |
| 830 | } catch (...) { |
| 831 | TraceEvent(SevWarn, |
| 832 | h.type == ssl_socket::handshake_type::client ? "N2_ConnectHandshakeUnknownError" |
| 833 | : "N2_AcceptHandshakeUnknownError") |
| 834 | .detail("BackgroundThread", true); |
| 835 | h.done.sendError(connection_failed()); |
| 836 | } |
| 837 | } |
| 838 | }; |
| 839 | |
| 840 | class SSLConnection final : public IConnection, ReferenceCounted<SSLConnection> { |