summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mysql-test/r/pool_of_threads.result4
-rw-r--r--mysql-test/t/pool_of_threads.test5
-rw-r--r--vio/viosocket.c24
3 files changed, 18 insertions, 15 deletions
diff --git a/mysql-test/r/pool_of_threads.result b/mysql-test/r/pool_of_threads.result
index 7acb45121d6..c151805e151 100644
--- a/mysql-test/r/pool_of_threads.result
+++ b/mysql-test/r/pool_of_threads.result
@@ -2157,10 +2157,10 @@ Warnings:
Warning 1052 Column 'kundentyp' in group statement is ambiguous
drop table t1;
SET optimizer_switch=@save_optimizer_switch;
-SELECT sleep(5);
+SELECT sleep(5.5);
SELECT sleep(5);
# -- Success: more than --thread_pool_max_threads normal connections not possible
-sleep(5)
+sleep(5.5)
0
sleep(5)
0
diff --git a/mysql-test/t/pool_of_threads.test b/mysql-test/t/pool_of_threads.test
index 4600128ff43..24e0218db62 100644
--- a/mysql-test/t/pool_of_threads.test
+++ b/mysql-test/t/pool_of_threads.test
@@ -17,7 +17,10 @@ SET optimizer_switch=@save_optimizer_switch;
# First set two connections running, and check that extra connection
# on normal port fails due to--thread-pool-max_threads=2
connection default;
-send SELECT sleep(5);
+
+# Sleep for slightly longer than 5 sec to trigger MDEV-4566
+# (abort in interruptible wait connection check)
+send SELECT sleep(5.5);
--sleep 1
connect(con2,localhost,root,,);
diff --git a/vio/viosocket.c b/vio/viosocket.c
index f84d7e802be..da5f640fc62 100644
--- a/vio/viosocket.c
+++ b/vio/viosocket.c
@@ -42,21 +42,21 @@ static void (*before_io_wait)(void)= 0;
static void (*after_io_wait)(void)= 0;
/* Wait callback macros (both performance schema and threadpool */
-#define START_SOCKET_WAIT(locker, state_ptr, sock, which) \
+#define START_SOCKET_WAIT(locker, state_ptr, sock, which, timeout) \
do \
{ \
MYSQL_START_SOCKET_WAIT(locker, state_ptr, sock, \
which, 0); \
- if (before_io_wait) \
+ if (timeout && before_io_wait) \
before_io_wait(); \
} while(0)
-#define END_SOCKET_WAIT(locker) \
+#define END_SOCKET_WAIT(locker,timeout) \
do \
{ \
MYSQL_END_SOCKET_WAIT(locker, 0); \
- if (after_io_wait) \
+ if (timeout && after_io_wait) \
after_io_wait(); \
} while(0)
@@ -930,11 +930,11 @@ int vio_io_wait(Vio *vio, enum enum_vio_io_event event, int timeout)
if (timeout != 0 && vio->async_context && vio->async_context->active)
{
START_SOCKET_WAIT(locker, &state, vio->mysql_socket,
- PSI_SOCKET_SELECT);
+ PSI_SOCKET_SELECT, timeout);
ret= my_io_wait_async(vio->async_context, event, timeout);
if (ret == 0)
errno= SOCKET_ETIMEDOUT;
- END_SOCKET_WAIT(locker);
+ END_SOCKET_WAIT(locker,timeout);
DBUG_RETURN(ret);
}
@@ -959,7 +959,7 @@ int vio_io_wait(Vio *vio, enum enum_vio_io_event event, int timeout)
break;
}
- START_SOCKET_WAIT(locker, &state, vio->mysql_socket, PSI_SOCKET_SELECT);
+ START_SOCKET_WAIT(locker, &state, vio->mysql_socket, PSI_SOCKET_SELECT, timeout);
/*
Wait for the I/O event and return early in case of
error or timeout.
@@ -982,7 +982,7 @@ int vio_io_wait(Vio *vio, enum enum_vio_io_event event, int timeout)
break;
}
- END_SOCKET_WAIT(locker);
+ END_SOCKET_WAIT(locker, timeout);
DBUG_RETURN(ret);
}
@@ -1004,11 +1004,11 @@ int vio_io_wait(Vio *vio, enum enum_vio_io_event event, int timeout)
if (timeout != 0 && vio->async_context && vio->async_context->active)
{
START_SOCKET_WAIT(locker, &state, vio->mysql_socket,
- PSI_SOCKET_SELECT);
+ PSI_SOCKET_SELECT, timeout);
ret= my_io_wait_async(vio->async_context, event, timeout);
if (ret == 0)
WSASetLastError(SOCKET_ETIMEDOUT);
- END_SOCKET_WAIT(locker);
+ END_SOCKET_WAIT(locker, timeout);
DBUG_RETURN(ret);
}
@@ -1039,12 +1039,12 @@ int vio_io_wait(Vio *vio, enum enum_vio_io_event event, int timeout)
break;
}
- START_SOCKET_WAIT(locker, &state, vio->mysql_socket, PSI_SOCKET_SELECT);
+ START_SOCKET_WAIT(locker, &state, vio->mysql_socket, PSI_SOCKET_SELECT, timeout);
/* The first argument is ignored on Windows. */
ret= select(0, &readfds, &writefds, &exceptfds, (timeout >= 0) ? &tm : NULL);
- END_SOCKET_WAIT(locker);
+ END_SOCKET_WAIT(locker, timeout);
/* Set error code to indicate a timeout error. */
if (ret == 0)