MCPcopy Create free account
hub / github.com/apache/cloudberry / pgtls_close

Function pgtls_close

src/interfaces/libpq/fe-secure-openssl.c:1473–1535  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1471}
1472
1473void
1474pgtls_close(PGconn *conn)
1475{
1476 bool destroy_needed = false;
1477
1478 if (conn->ssl_in_use)
1479 {
1480 if (conn->ssl)
1481 {
1482 /*
1483 * We can't destroy everything SSL-related here due to the
1484 * possible later calls to OpenSSL routines which may need our
1485 * thread callbacks, so set a flag here and check at the end.
1486 */
1487
1488 SSL_shutdown(conn->ssl);
1489 SSL_free(conn->ssl);
1490 conn->ssl = NULL;
1491 conn->ssl_in_use = false;
1492
1493 destroy_needed = true;
1494 }
1495
1496 if (conn->peer)
1497 {
1498 X509_free(conn->peer);
1499 conn->peer = NULL;
1500 }
1501
1502#ifdef USE_SSL_ENGINE
1503 if (conn->engine)
1504 {
1505 ENGINE_finish(conn->engine);
1506 ENGINE_free(conn->engine);
1507 conn->engine = NULL;
1508 }
1509#endif
1510 }
1511 else
1512 {
1513 /*
1514 * In the non-SSL case, just remove the crypto callbacks if the
1515 * connection has then loaded. This code path has no dependency on
1516 * any pending SSL calls.
1517 */
1518 if (conn->crypto_loaded)
1519 destroy_needed = true;
1520 }
1521
1522 /*
1523 * This will remove our crypto locking hooks if this is the last
1524 * connection using libcrypto which means we must wait to call it until
1525 * after all the potential SSL calls have been made, otherwise we can end
1526 * up with a race condition and possible deadlocks.
1527 *
1528 * See comments above destroy_ssl_system().
1529 */
1530 if (destroy_needed)

Callers 3

pgtls_open_clientFunction · 0.85
open_client_SSLFunction · 0.85
pqsecure_closeFunction · 0.85

Calls 1

destroy_ssl_systemFunction · 0.85

Tested by

no test coverage detected