MCPcopy Create free account
hub / github.com/Snapchat/KeyDB / connTLSAccept

Function connTLSAccept

src/tls.cpp:1015–1044  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1013}
1014
1015static int connTLSAccept(connection *_conn, ConnectionCallbackFunc accept_handler) {
1016 tls_connection *conn = (tls_connection *) _conn;
1017 int ret;
1018
1019 serverAssert(conn->el == serverTL->el);
1020
1021 if (conn->c.state != CONN_STATE_ACCEPTING) return C_ERR;
1022 ERR_clear_error();
1023
1024 /* Try to accept */
1025 conn->c.conn_handler = accept_handler;
1026 ret = SSL_accept(conn->ssl);
1027
1028 if (ret <= 0) {
1029 WantIOType want = WANT_INVALID;
1030 if (!handleSSLReturnCode(conn, ret, &want)) {
1031 registerSSLEvent(conn, want); /* We'll fire back */
1032 return C_OK;
1033 } else {
1034 conn->c.state = CONN_STATE_ERROR;
1035 return C_ERR;
1036 }
1037 }
1038
1039 conn->c.state = CONN_STATE_CONNECTED;
1040 if (!callHandler((connection *) conn, conn->c.conn_handler)) return C_OK;
1041 conn->c.conn_handler = NULL;
1042
1043 return C_OK;
1044}
1045
1046static int connTLSConnect(connection *conn_, const char *addr, int port, const char *src_addr, ConnectionCallbackFunc connect_handler) {
1047 tls_connection *conn = (tls_connection *) conn_;

Callers

nothing calls this directly

Calls 3

handleSSLReturnCodeFunction · 0.85
registerSSLEventFunction · 0.85
callHandlerFunction · 0.85

Tested by

no test coverage detected