size_t vio_ssl_write(Vio *vio, const uchar *buf, size_t size) { int ret; SSL *ssl= vio->ssl_arg; DBUG_ENTER("vio_ssl_write"); while ((ret= SSL_write(ssl, buf, size)) < 0) { enum enum_vio_io_event event; /* Process the SSL I/O error. */ if (!ssl_should_retry(vio, ret, &event)) break; /* Attempt to wait for an I/O event. */ if (vio_socket_io_wait(vio, event)) break; } DBUG_RETURN(ret < 0 ? -1 : ret); }
static int ssl_handshake_loop(Vio *vio, SSL *ssl, ssl_handshake_func_t func, unsigned long *ssl_errno_holder) { int ret; vio->ssl_arg= ssl; /* Initiate the SSL handshake. */ while (1) { enum enum_vio_io_event event; #ifndef HAVE_YASSL /* OpenSSL: check that the SSL thread's error queue is cleared. Otherwise SSL-handshake-function returns an error from the error queue, when the function failed because it would block. */ DBUG_ASSERT(ERR_peek_error() == 0); #endif ret= func(ssl); if (ret >= 1) break; /* Process the SSL I/O error. */ if (!ssl_should_retry(vio, ret, &event, ssl_errno_holder)) break; /* Wait for I/O so that the handshake can proceed. */ if (vio_socket_io_wait(vio, event)) break; } vio->ssl_arg= NULL; return ret; }
size_t vio_ssl_write(Vio *vio, const uchar *buf, size_t size) { int ret; SSL *ssl= vio->ssl_arg; unsigned long ssl_errno_not_used; DBUG_ENTER("vio_ssl_write"); while (1) { enum enum_vio_io_event event; #ifndef HAVE_YASSL /* OpenSSL: check that the SSL thread's error queue is cleared. Otherwise SSL_write() returns an error from the error queue, when SSL_write() failed because it would block. */ DBUG_ASSERT(ERR_peek_error() == 0); #endif ret= SSL_write(ssl, buf, (int)size); if (ret >= 0) break; /* Process the SSL I/O error. */ if (!ssl_should_retry(vio, ret, &event, &ssl_errno_not_used)) break; /* Attempt to wait for an I/O event. */ if (vio_socket_io_wait(vio, event)) break; } DBUG_RETURN(ret < 0 ? -1 : ret); }
static int ssl_handshake_loop(Vio *vio, SSL *ssl, ssl_handshake_func_t func) { int ret; vio->ssl_arg= ssl; /* Initiate the SSL handshake. */ while ((ret= func(ssl)) < 1) { enum enum_vio_io_event event; /* Process the SSL I/O error. */ if (!ssl_should_retry(vio, ret, &event)) break; /* Wait for I/O so that the handshake can proceed. */ if (vio_socket_io_wait(vio, event)) break; } vio->ssl_arg= NULL; return ret; }