Skip to content

Commit

Permalink
MDEV-32567 Remove thr_alarm from server codebase
Browse files Browse the repository at this point in the history
This allows to simplify net_real_read() and net_real_write() a bit.

Removed some superfluous #ifdef/ifndef MYSQL_SERVER from net_serv.cc
The code always runs in server, either normal or embedded.
Dead code for switching socket between blocking and non-blocking modes,
is also removed.

Removed pthread_kill() with alarm signal that woke up main thread on
server shutdown. Used shutdown(2) on polling sockets instead, to the same
effect.

Removed yet another superstitious pthread_kill(), that ran on non-Windows
in terminate_slave_thread().
  • Loading branch information
vaintroub authored and grooverdan committed Nov 23, 2023
1 parent 3424ed7 commit 013fc02
Show file tree
Hide file tree
Showing 19 changed files with 123 additions and 1,513 deletions.
1 change: 0 additions & 1 deletion config.h.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,6 @@
#cmakedefine HAVE_GCC_C11_ATOMICS 1
#cmakedefine HAVE_SOLARIS_ATOMIC 1
#cmakedefine NO_FCNTL_NONBLOCK 1
#cmakedefine NO_ALARM 1

#cmakedefine _LARGE_FILES 1
#cmakedefine _LARGEFILE_SOURCE 1
Expand Down
1 change: 0 additions & 1 deletion configure.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -836,7 +836,6 @@ CHECK_CXX_SOURCE_COMPILES("
"
HAVE_SOLARIS_STYLE_GETHOST)

SET(NO_ALARM 1 CACHE BOOL "No need to use alarm to implement timeout")

# As a consequence of ALARMs no longer being used, thread
# notification for KILL must close the socket to wake up
Expand Down
1 change: 0 additions & 1 deletion include/my_pthread.h
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,6 @@ extern int my_pthread_create_detached;
#define PTHREAD_CREATE_DETACHED &my_pthread_create_detached
#define PTHREAD_SCOPE_SYSTEM PTHREAD_SCOPE_GLOBAL
#define PTHREAD_SCOPE_PROCESS PTHREAD_SCOPE_LOCAL
#define USE_ALARM_THREAD
#endif /* defined(PTHREAD_SCOPE_GLOBAL) && !defined(PTHREAD_SCOPE_SYSTEM) */

#if defined(_BSDI_VERSION) && _BSDI_VERSION < 199910
Expand Down
115 changes: 0 additions & 115 deletions include/thr_alarm.h

This file was deleted.

21 changes: 0 additions & 21 deletions mysql-test/suite/sys_vars/r/debug_no_thread_alarm_basic.result

This file was deleted.

15 changes: 0 additions & 15 deletions mysql-test/suite/sys_vars/r/sysvars_debug.result
Original file line number Diff line number Diff line change
Expand Up @@ -46,21 +46,6 @@ ENUM_VALUE_LIST OFF,ON
READ_ONLY YES
COMMAND_LINE_ARGUMENT OPTIONAL
GLOBAL_VALUE_PATH NULL
VARIABLE_NAME DEBUG_NO_THREAD_ALARM
SESSION_VALUE NULL
GLOBAL_VALUE OFF
GLOBAL_VALUE_ORIGIN COMPILE-TIME
DEFAULT_VALUE OFF
VARIABLE_SCOPE GLOBAL
VARIABLE_TYPE BOOLEAN
VARIABLE_COMMENT Disable system thread alarm calls. Disabling it may be useful in debugging or testing, never do it in production
NUMERIC_MIN_VALUE NULL
NUMERIC_MAX_VALUE NULL
NUMERIC_BLOCK_SIZE NULL
ENUM_VALUE_LIST OFF,ON
READ_ONLY YES
COMMAND_LINE_ARGUMENT OPTIONAL
GLOBAL_VALUE_PATH NULL
VARIABLE_NAME DEBUG_SYNC
SESSION_VALUE ON - current signals: ''
GLOBAL_VALUE NULL
Expand Down
21 changes: 0 additions & 21 deletions mysql-test/suite/sys_vars/t/debug_no_thread_alarm_basic.test

This file was deleted.

2 changes: 1 addition & 1 deletion mysys/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ SET(MYSYS_SOURCES array.c charset-def.c charset.c my_default.c
my_static.c my_symlink.c my_symlink2.c my_sync.c my_thr_init.c
my_basename.c
my_write.c ptr_cmp.c queues.c stacktrace.c
string.c thr_alarm.c thr_lock.c thr_mutex.c
string.c thr_lock.c thr_mutex.c
thr_rwlock.c thr_timer.c
tree.c typelib.c base64.c my_memmem.c
my_getpagesize.c
Expand Down
12 changes: 2 additions & 10 deletions mysys/my_init.c
Original file line number Diff line number Diff line change
Expand Up @@ -468,7 +468,7 @@ PSI_mutex_key key_LOCK_localtime_r;

PSI_mutex_key key_BITMAP_mutex, key_IO_CACHE_append_buffer_lock,
key_IO_CACHE_SHARE_mutex, key_KEY_CACHE_cache_lock,
key_LOCK_alarm, key_LOCK_timer,
key_LOCK_timer,
key_my_thread_var_mutex, key_THR_LOCK_charset, key_THR_LOCK_heap,
key_THR_LOCK_lock, key_THR_LOCK_malloc,
key_THR_LOCK_mutex, key_THR_LOCK_myisam, key_THR_LOCK_net,
Expand All @@ -487,7 +487,6 @@ static PSI_mutex_info all_mysys_mutexes[]=
{ &key_IO_CACHE_append_buffer_lock, "IO_CACHE::append_buffer_lock", 0},
{ &key_IO_CACHE_SHARE_mutex, "IO_CACHE::SHARE_mutex", 0},
{ &key_KEY_CACHE_cache_lock, "KEY_CACHE::cache_lock", 0},
{ &key_LOCK_alarm, "LOCK_alarm", PSI_FLAG_GLOBAL},
{ &key_LOCK_timer, "LOCK_timer", PSI_FLAG_GLOBAL},
{ &key_my_thread_var_mutex, "my_thread_var::mutex", 0},
{ &key_THR_LOCK_charset, "THR_LOCK_charset", PSI_FLAG_GLOBAL},
Expand All @@ -504,13 +503,12 @@ static PSI_mutex_info all_mysys_mutexes[]=
{ &key_LOCK_uuid_generator, "LOCK_uuid_generator", PSI_FLAG_GLOBAL }
};

PSI_cond_key key_COND_alarm, key_COND_timer, key_IO_CACHE_SHARE_cond,
PSI_cond_key key_COND_timer, key_IO_CACHE_SHARE_cond,
key_IO_CACHE_SHARE_cond_writer, key_my_thread_var_suspend,
key_THR_COND_threads, key_WT_RESOURCE_cond;

static PSI_cond_info all_mysys_conds[]=
{
{ &key_COND_alarm, "COND_alarm", PSI_FLAG_GLOBAL},
{ &key_COND_timer, "COND_timer", PSI_FLAG_GLOBAL},
{ &key_IO_CACHE_SHARE_cond, "IO_CACHE_SHARE::cond", 0},
{ &key_IO_CACHE_SHARE_cond_writer, "IO_CACHE_SHARE::cond_writer", 0},
Expand All @@ -526,16 +524,10 @@ static PSI_rwlock_info all_mysys_rwlocks[]=
{ &key_SAFEHASH_mutex, "SAFE_HASH::mutex", 0}
};

#ifdef USE_ALARM_THREAD
PSI_thread_key key_thread_alarm;
#endif
PSI_thread_key key_thread_timer;

static PSI_thread_info all_mysys_threads[]=
{
#ifdef USE_ALARM_THREAD
{ &key_thread_alarm, "alarm", PSI_FLAG_GLOBAL},
#endif
{ &key_thread_timer, "statement_timer", PSI_FLAG_GLOBAL}
};

Expand Down
5 changes: 0 additions & 5 deletions mysys/my_pthread.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
#include "mysys_priv.h"
#include <signal.h>
#include <m_string.h>
#include <thr_alarm.h>
#include <my_pthread.h>

#if (defined(__BSD__) || defined(_BSDI_VERSION))
Expand Down Expand Up @@ -234,11 +233,7 @@ void *sigwait_thread(void *set_arg)
sigaction(i, &sact, (struct sigaction*) 0);
}
}
/* Ensure that init_thr_alarm() is called */
DBUG_ASSERT(thr_client_alarm);
sigaddset(set, thr_client_alarm);
pthread_sigmask(SIG_UNBLOCK,(sigset_t*) set,(sigset_t*) 0);
alarm_thread=pthread_self(); /* For thr_alarm */

for (;;)
{ /* Wait for signals */
Expand Down
7 changes: 2 additions & 5 deletions mysys/mysys_priv.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,20 +43,17 @@ extern PSI_mutex_key key_LOCK_localtime_r;
#endif /* !defined(HAVE_LOCALTIME_R) || !defined(HAVE_GMTIME_R) */

extern PSI_mutex_key key_BITMAP_mutex, key_IO_CACHE_append_buffer_lock,
key_IO_CACHE_SHARE_mutex, key_KEY_CACHE_cache_lock, key_LOCK_alarm,
key_IO_CACHE_SHARE_mutex, key_KEY_CACHE_cache_lock,
key_my_thread_var_mutex, key_THR_LOCK_charset, key_THR_LOCK_heap,
key_THR_LOCK_lock, key_THR_LOCK_malloc,
key_THR_LOCK_mutex, key_THR_LOCK_myisam, key_THR_LOCK_net,
key_THR_LOCK_open, key_THR_LOCK_threads, key_LOCK_uuid_generator,
key_TMPDIR_mutex, key_THR_LOCK_myisam_mmap, key_LOCK_timer;

extern PSI_cond_key key_COND_alarm, key_COND_timer, key_IO_CACHE_SHARE_cond,
extern PSI_cond_key key_COND_timer, key_IO_CACHE_SHARE_cond,
key_IO_CACHE_SHARE_cond_writer, key_my_thread_var_suspend,
key_THR_COND_threads;

#ifdef USE_ALARM_THREAD
extern PSI_thread_key key_thread_alarm;
#endif /* USE_ALARM_THREAD */
extern PSI_thread_key key_thread_timer;
extern PSI_rwlock_key key_SAFEHASH_mutex;

Expand Down

0 comments on commit 013fc02

Please sign in to comment.