MCPcopy Create free account
hub / github.com/Tiiny-AI/PowerInfer / ssl_new

Function ssl_new

examples/server/httplib.h:7611–7639  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

7609
7610template <typename U, typename V>
7611inline SSL *ssl_new(socket_t sock, SSL_CTX *ctx, std::mutex &ctx_mutex,
7612 U SSL_connect_or_accept, V setup) {
7613 SSL *ssl = nullptr;
7614 {
7615 std::lock_guard<std::mutex> guard(ctx_mutex);
7616 ssl = SSL_new(ctx);
7617 }
7618
7619 if (ssl) {
7620 set_nonblocking(sock, true);
7621 auto bio = BIO_new_socket(static_cast<int>(sock), BIO_NOCLOSE);
7622 BIO_set_nbio(bio, 1);
7623 SSL_set_bio(ssl, bio, bio);
7624
7625 if (!setup(ssl) || SSL_connect_or_accept(ssl) != 1) {
7626 SSL_shutdown(ssl);
7627 {
7628 std::lock_guard<std::mutex> guard(ctx_mutex);
7629 SSL_free(ssl);
7630 }
7631 set_nonblocking(sock, false);
7632 return nullptr;
7633 }
7634 BIO_set_nbio(bio, 0);
7635 set_nonblocking(sock, false);
7636 }
7637
7638 return ssl;
7639}
7640
7641inline void ssl_delete(std::mutex &ctx_mutex, SSL *ssl,
7642 bool shutdown_gracefully) {

Callers 2

initialize_sslMethod · 0.85

Calls 2

set_nonblockingFunction · 0.85
setupFunction · 0.50

Tested by

no test coverage detected