Skip to content

Commit 834ec12

Browse files
author
prabakaran thirumalai
committed
Bug#16301715 REMOVE DEAD CODE DEFINED WITH DONT_USE_THR_ALARM
Description: Dead code defined under DONT_USE_THR_ALARM, HAVE_rts_threads are removed. Also removed USE_ALARM_THREAD which is defined only for HAVE_rts_threads
1 parent 81a73b8 commit 834ec12

File tree

9 files changed

+3
-182
lines changed

9 files changed

+3
-182
lines changed

include/my_pthread.h

+1-18
Original file line numberDiff line numberDiff line change
@@ -189,11 +189,6 @@ int pthread_cancel(pthread_t thread);
189189

190190
#else /* Normal threads */
191191

192-
#ifdef HAVE_rts_threads
193-
#define sigwait org_sigwait
194-
#include <signal.h>
195-
#undef sigwait
196-
#endif
197192
#include <pthread.h>
198193
#ifndef _REENTRANT
199194
#define _REENTRANT
@@ -223,18 +218,6 @@ typedef void *(* pthread_handler)(void *);
223218
#endif
224219
#define my_pthread_once(C,F) pthread_once(C,F)
225220

226-
/* Test first for RTS or FSU threads */
227-
228-
#if defined(PTHREAD_SCOPE_GLOBAL) && !defined(PTHREAD_SCOPE_SYSTEM)
229-
#define HAVE_rts_threads
230-
extern int my_pthread_create_detached;
231-
#define pthread_sigmask(A,B,C) sigprocmask((A),(B),(C))
232-
#define PTHREAD_CREATE_DETACHED &my_pthread_create_detached
233-
#define PTHREAD_SCOPE_SYSTEM PTHREAD_SCOPE_GLOBAL
234-
#define PTHREAD_SCOPE_PROCESS PTHREAD_SCOPE_LOCAL
235-
#define USE_ALARM_THREAD
236-
#endif /* defined(PTHREAD_SCOPE_GLOBAL) && !defined(PTHREAD_SCOPE_SYSTEM) */
237-
238221
#if defined(_BSDI_VERSION) && _BSDI_VERSION < 199910
239222
int sigwait(sigset_t *set, int *sig);
240223
#endif
@@ -260,7 +243,7 @@ extern int my_pthread_cond_init(pthread_cond_t *mp,
260243
#define pthread_sigmask(A,B,C) sigthreadmask((A),(B),(C))
261244
#endif
262245

263-
#if !defined(HAVE_SIGWAIT) && !defined(HAVE_rts_threads) && !defined(sigwait) && !defined(alpha_linux_port) && !defined(HAVE_NONPOSIX_SIGWAIT) && !defined(HAVE_DEC_3_2_THREADS) && !defined(_AIX)
246+
#if !defined(HAVE_SIGWAIT) && !defined(sigwait) && !defined(alpha_linux_port) && !defined(HAVE_NONPOSIX_SIGWAIT) && !defined(HAVE_DEC_3_2_THREADS) && !defined(_AIX)
264247
int sigwait(sigset_t *setp, int *sigp); /* Use our implemention */
265248
#endif
266249

include/thr_alarm.h

-31
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,8 @@
2121
extern "C" {
2222
#endif
2323

24-
#ifndef USE_ALARM_THREAD
2524
#define USE_ONE_SIGNAL_HAND /* One must call process_alarm */
26-
#endif
27-
#ifdef HAVE_rts_threads
28-
#undef USE_ONE_SIGNAL_HAND
29-
#define USE_ALARM_THREAD
30-
#define THR_SERVER_ALARM SIGUSR1
31-
#else
3225
#define THR_SERVER_ALARM SIGALRM
33-
#endif
3426

3527
typedef struct st_alarm_info
3628
{
@@ -41,26 +33,6 @@ typedef struct st_alarm_info
4133

4234
void thr_alarm_info(ALARM_INFO *info);
4335

44-
#if defined(DONT_USE_THR_ALARM)
45-
46-
#define USE_ALARM_THREAD
47-
#undef USE_ONE_SIGNAL_HAND
48-
49-
typedef my_bool thr_alarm_t;
50-
typedef my_bool ALARM;
51-
52-
#define thr_alarm_init(A) (*(A))=0
53-
#define thr_alarm_in_use(A) (*(A) != 0)
54-
#define thr_end_alarm(A)
55-
#define thr_alarm(A,B,C) ((*(A)=1)-1)
56-
/* The following should maybe be (*(A)) */
57-
#define thr_got_alarm(A) 0
58-
#define init_thr_alarm(A)
59-
#define thr_alarm_kill(A)
60-
#define resize_thr_alarm(N)
61-
#define end_thr_alarm(A)
62-
63-
#else
6436
#if defined(__WIN__)
6537
typedef struct st_thr_alarm_entry
6638
{
@@ -101,9 +73,6 @@ sig_handler process_alarm(int);
10173
my_bool thr_got_alarm(thr_alarm_t *alrm);
10274
#endif
10375

104-
105-
#endif /* DONT_USE_THR_ALARM */
106-
10776
#ifdef __cplusplus
10877
}
10978
#endif /* __cplusplus */

mysys/my_init.c

-14
Original file line numberDiff line numberDiff line change
@@ -513,15 +513,6 @@ static PSI_cond_info all_mysys_conds[]=
513513
{ &key_THR_COND_threads, "THR_COND_threads", 0}
514514
};
515515

516-
#ifdef USE_ALARM_THREAD
517-
PSI_thread_key key_thread_alarm;
518-
519-
static PSI_thread_info all_mysys_threads[]=
520-
{
521-
{ &key_thread_alarm, "alarm", PSI_FLAG_GLOBAL}
522-
};
523-
#endif /* USE_ALARM_THREAD */
524-
525516
#ifdef HUGETLB_USE_PROC_MEMINFO
526517
PSI_file_key key_file_proc_meminfo;
527518
#endif /* HUGETLB_USE_PROC_MEMINFO */
@@ -552,11 +543,6 @@ void my_init_mysys_psi_keys()
552543
count= sizeof(all_mysys_conds)/sizeof(all_mysys_conds[0]);
553544
mysql_cond_register(category, all_mysys_conds, count);
554545

555-
#ifdef USE_ALARM_THREAD
556-
count= sizeof(all_mysys_threads)/sizeof(all_mysys_threads[0]);
557-
mysql_thread_register(category, all_mysys_threads, count);
558-
#endif /* USE_ALARM_THREAD */
559-
560546
count= sizeof(all_mysys_files)/sizeof(all_mysys_files[0]);
561547
mysql_file_register(category, all_mysys_files, count);
562548

mysys/my_pthread.c

+1-8
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,6 @@ void *my_pthread_getspecific_imp(pthread_key_t key)
4444
}
4545
#endif
4646

47-
/*
48-
Some functions for RTS threads, AIX, Siemens Unix and UnixWare 7
49-
(and DEC OSF/1 3.2 too)
50-
*/
51-
52-
int my_pthread_create_detached=1;
53-
5447
#if defined(HAVE_NONPOSIX_SIGWAIT) || defined(HAVE_DEC_3_2_THREADS)
5548

5649
int my_sigwait(const sigset_t *set,int *sig)
@@ -117,7 +110,7 @@ struct tm *gmtime_r(const time_t *clock, struct tm *res)
117110
** Author: Gary Wisniewski <garyw@spidereye.com.au>, much modified by Monty
118111
****************************************************************************/
119112

120-
#if !defined(HAVE_SIGWAIT) && !defined(sigwait) && !defined(__WIN__) && !defined(HAVE_rts_threads) && !defined(HAVE_NONPOSIX_SIGWAIT) && !defined(HAVE_DEC_3_2_THREADS)
113+
#if !defined(HAVE_SIGWAIT) && !defined(sigwait) && !defined(__WIN__) && !defined(HAVE_NONPOSIX_SIGWAIT) && !defined(HAVE_DEC_3_2_THREADS)
121114

122115
#if !defined(DONT_USE_SIGSUSPEND)
123116

mysys/mysys_priv.h

-4
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,6 @@ extern PSI_cond_key key_COND_alarm, key_IO_CACHE_SHARE_cond,
4848
key_IO_CACHE_SHARE_cond_writer, key_my_thread_var_suspend,
4949
key_THR_COND_threads;
5050

51-
#ifdef USE_ALARM_THREAD
52-
extern PSI_thread_key key_thread_alarm;
53-
#endif /* USE_ALARM_THREAD */
54-
5551
#endif /* HAVE_PSI_INTERFACE */
5652

5753
extern PSI_stage_info stage_waiting_for_table_level_lock;

mysys/thr_alarm.c

+1-101
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@
1717
#define FORCE_DBUG_OFF
1818
#include "mysys_priv.h"
1919
#include <my_global.h>
20-
21-
#if !defined(DONT_USE_THR_ALARM)
2220
#include <errno.h>
2321
#include <my_pthread.h>
2422
#include <signal.h>
@@ -53,12 +51,7 @@ pthread_t alarm_thread;
5351

5452
#define MY_THR_ALARM_QUEUE_EXTENT 10
5553

56-
#ifdef USE_ALARM_THREAD
57-
static void *alarm_handler(void *arg);
58-
#define reschedule_alarms() mysql_cond_signal(&COND_alarm)
59-
#else
6054
#define reschedule_alarms() pthread_kill(alarm_thread,THR_SERVER_ALARM)
61-
#endif
6255

6356
static sig_handler thread_alarm(int sig __attribute__((unused)));
6457

@@ -84,27 +77,14 @@ void init_thr_alarm(uint max_alarms)
8477
thr_client_alarm= SIGALRM;
8578
else
8679
thr_client_alarm= SIGUSR1;
87-
#ifndef USE_ALARM_THREAD
8880
if (thd_lib_detected != THD_LIB_LT)
89-
#endif
9081
{
9182
my_sigset(thr_client_alarm, thread_alarm);
9283
}
9384
sigemptyset(&s);
9485
sigaddset(&s, THR_SERVER_ALARM);
9586
alarm_thread=pthread_self();
96-
#if defined(USE_ALARM_THREAD)
97-
{
98-
pthread_attr_t thr_attr;
99-
pthread_attr_init(&thr_attr);
100-
pthread_attr_setscope(&thr_attr,PTHREAD_SCOPE_PROCESS);
101-
pthread_attr_setdetachstate(&thr_attr,PTHREAD_CREATE_DETACHED);
102-
pthread_attr_setstacksize(&thr_attr,8196);
103-
mysql_thread_create(key_thread_alarm,
104-
&alarm_thread, &thr_attr, alarm_handler, NULL);
105-
pthread_attr_destroy(&thr_attr);
106-
}
107-
#elif defined(USE_ONE_SIGNAL_HAND)
87+
#if defined(USE_ONE_SIGNAL_HAND)
10888
pthread_sigmask(SIG_BLOCK, &s, NULL); /* used with sigwait() */
10989
if (thd_lib_detected == THD_LIB_LT)
11090
{
@@ -313,18 +293,14 @@ sig_handler process_alarm(int sig __attribute__((unused)))
313293
process_alarm() at the same time
314294
*/
315295

316-
#ifndef USE_ALARM_THREAD
317296
pthread_sigmask(SIG_SETMASK,&full_signal_set,&old_mask);
318297
mysql_mutex_lock(&LOCK_alarm);
319-
#endif
320298
process_alarm_part2(sig);
321-
#ifndef USE_ALARM_THREAD
322299
#if defined(SIGNAL_HANDLER_RESET_ON_DELIVERY) && !defined(USE_ONE_SIGNAL_HAND)
323300
my_sigset(THR_SERVER_ALARM,process_alarm);
324301
#endif
325302
mysql_mutex_unlock(&LOCK_alarm);
326303
pthread_sigmask(SIG_SETMASK,&old_mask,NULL);
327-
#endif
328304
return;
329305
}
330306

@@ -358,10 +334,8 @@ static sig_handler process_alarm_part2(int sig __attribute__((unused)))
358334
else
359335
i++; /* Signal next thread */
360336
}
361-
#ifndef USE_ALARM_THREAD
362337
if (alarm_queue.elements)
363338
alarm(1); /* Signal soon again */
364-
#endif
365339
}
366340
else
367341
{
@@ -387,7 +361,6 @@ static sig_handler process_alarm_part2(int sig __attribute__((unused)))
387361
queue_replaced(&alarm_queue);
388362
}
389363
}
390-
#ifndef USE_ALARM_THREAD
391364
if (alarm_queue.elements)
392365
{
393366
#ifdef __bsdi__
@@ -396,7 +369,6 @@ static sig_handler process_alarm_part2(int sig __attribute__((unused)))
396369
alarm((uint) (alarm_data->expire_time-now));
397370
next_alarm_expire_time= alarm_data->expire_time;
398371
}
399-
#endif
400372
}
401373
}
402374
else
@@ -533,66 +505,6 @@ static sig_handler thread_alarm(int sig __attribute__((unused)))
533505
#define tv_nsec ts_nsec
534506
#endif
535507

536-
/* set up a alarm thread with uses 'sleep' to sleep between alarms */
537-
538-
#ifdef USE_ALARM_THREAD
539-
static void *alarm_handler(void *arg __attribute__((unused)))
540-
{
541-
int error;
542-
struct timespec abstime;
543-
#ifdef MAIN
544-
puts("Starting alarm thread");
545-
#endif
546-
my_thread_init();
547-
alarm_thread_running= 1;
548-
mysql_mutex_lock(&LOCK_alarm);
549-
for (;;)
550-
{
551-
if (alarm_queue.elements)
552-
{
553-
ulong sleep_time,now= my_time(0);
554-
if (alarm_aborted)
555-
sleep_time=now+1;
556-
else
557-
sleep_time= ((ALARM*) queue_top(&alarm_queue))->expire_time;
558-
if (sleep_time > now)
559-
{
560-
abstime.tv_sec=sleep_time;
561-
abstime.tv_nsec=0;
562-
next_alarm_expire_time= sleep_time;
563-
if ((error= mysql_cond_timedwait(&COND_alarm, &LOCK_alarm, &abstime)) &&
564-
error != ETIME && error != ETIMEDOUT)
565-
{
566-
#ifdef MAIN
567-
printf("Got error: %d from ptread_cond_timedwait (errno: %d)\n",
568-
error,errno);
569-
#endif
570-
}
571-
}
572-
}
573-
else if (alarm_aborted == -1)
574-
break;
575-
else
576-
{
577-
next_alarm_expire_time= ~ (time_t) 0;
578-
if ((error= mysql_cond_wait(&COND_alarm, &LOCK_alarm)))
579-
{
580-
#ifdef MAIN
581-
printf("Got error: %d from ptread_cond_wait (errno: %d)\n",
582-
error,errno);
583-
#endif
584-
}
585-
}
586-
process_alarm(0);
587-
}
588-
memset(&alarm_thread, 0, sizeof(alarm_thread)); /* For easy debugging */
589-
alarm_thread_running= 0;
590-
mysql_cond_signal(&COND_alarm);
591-
mysql_mutex_unlock(&LOCK_alarm);
592-
pthread_exit(0);
593-
return 0; /* Impossible */
594-
}
595-
#endif /* USE_ALARM_THREAD */
596508

597509
/*****************************************************************************
598510
thr_alarm for win95
@@ -680,14 +592,11 @@ void resize_thr_alarm(uint max_alarms)
680592

681593
#endif /* __WIN__ */
682594

683-
#endif
684-
685595
/****************************************************************************
686596
Handling of test case (when compiled with -DMAIN)
687597
***************************************************************************/
688598

689599
#ifdef MAIN
690-
#if !defined(DONT_USE_THR_ALARM)
691600

692601
static mysql_cond_t COND_thread_count;
693602
static mysql_mutex_t LOCK_thread_count;
@@ -954,13 +863,4 @@ int main(int argc __attribute__((unused)),char **argv __attribute__((unused)))
954863
return 0;
955864
}
956865

957-
#else /* !defined(DONT_USE_ALARM_THREAD) */
958-
959-
int main(int argc __attribute__((unused)),char **argv __attribute__((unused)))
960-
{
961-
printf("thr_alarm disabled with DONT_USE_THR_ALARM\n");
962-
exit(1);
963-
}
964-
965-
#endif /* !defined(DONT_USE_ALARM_THREAD) */
966866
#endif /* MAIN */

sql/mysqld.cc

-2
Original file line numberDiff line numberDiff line change
@@ -1315,10 +1315,8 @@ static void close_connections(void)
13151315
LINT_INIT(error);
13161316
DBUG_PRINT("info",("Waiting for select thread"));
13171317

1318-
#ifndef DONT_USE_THR_ALARM
13191318
if (pthread_kill(select_thread, thr_client_alarm))
13201319
break; // allready dead
1321-
#endif
13221320
set_timespec(abstime, 2);
13231321
for (uint tmp=0 ; tmp < 10 && select_thread_in_use; tmp++)
13241322
{

sql/rpl_slave.cc

-2
Original file line numberDiff line numberDiff line change
@@ -948,15 +948,13 @@ terminate_slave_thread(THD *thd,
948948
DBUG_PRINT("loop", ("killing slave thread"));
949949

950950
mysql_mutex_lock(&thd->LOCK_thd_data);
951-
#ifndef DONT_USE_THR_ALARM
952951
/*
953952
Error codes from pthread_kill are:
954953
EINVAL: invalid signal number (can't happen)
955954
ESRCH: thread already killed (can happen, should be ignored)
956955
*/
957956
int err __attribute__((unused))= pthread_kill(thd->real_id, thr_client_alarm);
958957
DBUG_ASSERT(err != EINVAL);
959-
#endif
960958
thd->awake(THD::NOT_KILLED);
961959
mysql_mutex_unlock(&thd->LOCK_thd_data);
962960

sql/sql_test.cc

-2
Original file line numberDiff line numberDiff line change
@@ -499,7 +499,6 @@ Open streams: %10lu\n",
499499
(ulong) my_stream_opened);
500500

501501
ALARM_INFO alarm_info;
502-
#ifndef DONT_USE_THR_ALARM
503502
thr_alarm_info(&alarm_info);
504503
printf("\nAlarm status:\n\
505504
Active alarms: %u\n\
@@ -508,7 +507,6 @@ Next alarm time: %lu\n",
508507
alarm_info.active_alarms,
509508
alarm_info.max_used_alarms,
510509
alarm_info.next_alarm_time);
511-
#endif
512510
display_table_locks();
513511
#ifdef HAVE_MALLINFO
514512
struct mallinfo info= mallinfo();

0 commit comments

Comments
 (0)