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

Function handleSSLReturnCode

src/tls.cpp:746–771  ·  view source on GitHub ↗

Process the return code received from OpenSSL> * Update the want parameter with expected I/O. * Update the connection's error state if a real error has occured. * Returns an SSL error code, or 0 if no further handling is required. */

Source from the content-addressed store, hash-verified

744 * Returns an SSL error code, or 0 if no further handling is required.
745 */
746static int handleSSLReturnCode(tls_connection *conn, int ret_value, WantIOType *want) {
747 if (ret_value <= 0) {
748 int ssl_err = SSL_get_error(conn->ssl, ret_value);
749 switch (ssl_err) {
750 case SSL_ERROR_WANT_WRITE:
751 *want = WANT_WRITE;
752 return 0;
753 case SSL_ERROR_WANT_READ:
754 *want = WANT_READ;
755 return 0;
756 case SSL_ERROR_SYSCALL:
757 conn->c.last_errno = errno;
758 if (conn->ssl_error) zfree(conn->ssl_error);
759 conn->ssl_error = errno ? zstrdup(strerror(errno)) : NULL;
760 break;
761 default:
762 /* Error! */
763 updateTLSError(conn);
764 break;
765 }
766
767 return ssl_err;
768 }
769
770 return 0;
771}
772
773void registerSSLEvent(tls_connection *conn, WantIOType want) {
774 int mask = aeGetFileEvents(serverTL->el, conn->c.fd);

Callers 4

tlsHandleEventFunction · 0.85
connTLSAcceptFunction · 0.85
connTLSWriteFunction · 0.85
connTLSReadFunction · 0.85

Calls 3

zfreeFunction · 0.85
zstrdupFunction · 0.85
updateTLSErrorFunction · 0.85

Tested by

no test coverage detected