Skip to content

Commit 04789ec

Browse files
committed
MDEV-14781 - threadpool slowdown with slow ssl handshake.
Fix is not to use blocking socket IO during SSL handshake. With non-blocking socket IO, threadpool is able to utilize the wait notification callbacks, that vio_io_wait() is calling whenever socket would block.
1 parent 54b8856 commit 04789ec

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

vio/viossl.c

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,9 @@ static my_bool ssl_should_retry(Vio *vio, int ret, enum enum_vio_io_event *event
124124
default:
125125
should_retry= FALSE;
126126
ssl_set_sys_error(ssl_error);
127+
#ifndef HAVE_YASSL
128+
ERR_clear_error();
129+
#endif
127130
break;
128131
}
129132

@@ -315,21 +318,16 @@ static int ssl_do(struct st_VioSSLFd *ptr, Vio *vio, long timeout,
315318
{
316319
int r;
317320
SSL *ssl;
318-
my_bool unused;
319-
my_bool was_blocking;
320321
my_socket sd= mysql_socket_getfd(vio->mysql_socket);
321322
DBUG_ENTER("ssl_do");
322323
DBUG_PRINT("enter", ("ptr: %p, sd: %d ctx: %p",
323324
ptr, (int)sd, ptr->ssl_context));
324325

325-
/* Set socket to blocking if not already set */
326-
vio_blocking(vio, 1, &was_blocking);
327326

328327
if (!(ssl= SSL_new(ptr->ssl_context)))
329328
{
330329
DBUG_PRINT("error", ("SSL_new failure"));
331330
*errptr= ERR_get_error();
332-
vio_blocking(vio, was_blocking, &unused);
333331
DBUG_RETURN(1);
334332
}
335333
DBUG_PRINT("info", ("ssl: %p timeout: %ld", ssl, timeout));
@@ -360,7 +358,6 @@ static int ssl_do(struct st_VioSSLFd *ptr, Vio *vio, long timeout,
360358
DBUG_PRINT("error", ("SSL_connect/accept failure"));
361359
*errptr= SSL_errno(ssl, r);
362360
SSL_free(ssl);
363-
vio_blocking(vio, was_blocking, &unused);
364361
DBUG_RETURN(1);
365362
}
366363

@@ -371,7 +368,6 @@ static int ssl_do(struct st_VioSSLFd *ptr, Vio *vio, long timeout,
371368
*/
372369
if (vio_reset(vio, VIO_TYPE_SSL, SSL_get_fd(ssl), ssl, 0))
373370
{
374-
vio_blocking(vio, was_blocking, &unused);
375371
DBUG_RETURN(1);
376372
}
377373

0 commit comments

Comments
 (0)