summaryrefslogtreecommitdiff
path: root/mysys/thr_alarm.c.rej
blob: c991121052efe0d283c5ddd8b0c33c0734885606 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
***************
*** 76,96 ****
    alarm_aborted=0;
    init_queue(&alarm_queue,max_alarms+1,offsetof(ALARM,expire_time),0,
  	     compare_ulong,NullS);
!   sigfillset(&full_signal_set);			/* Neaded to block signals */
    pthread_mutex_init(&LOCK_alarm,MY_MUTEX_INIT_FAST);
    pthread_cond_init(&COND_alarm,NULL);
! #if THR_CLIENT_ALARM != SIGALRM || defined(USE_ALARM_THREAD)
! #if defined(HAVE_mit_thread)
!   sigset(THR_CLIENT_ALARM,thread_alarm);	/* int. thread system calls */
! #else
    {
!     struct sigaction sact;
!     sact.sa_flags = 0;
!     sact.sa_handler = thread_alarm;
!     sigaction(THR_CLIENT_ALARM, &sact, (struct sigaction*) 0);
    }
- #endif
- #endif
    sigemptyset(&s);
    sigaddset(&s, THR_SERVER_ALARM);
    alarm_thread=pthread_self();
--- 74,89 ----
    alarm_aborted=0;
    init_queue(&alarm_queue,max_alarms+1,offsetof(ALARM,expire_time),0,
  	     compare_ulong,NullS);
!   sigfillset(&full_signal_set);			/* Needed to block signals */
    pthread_mutex_init(&LOCK_alarm,MY_MUTEX_INIT_FAST);
    pthread_cond_init(&COND_alarm,NULL);
! #ifndef USE_ALARM_THREAD
!   if (thd_lib_detected != THD_LIB_LT)
! #endif
    {
!     my_sigset(thd_lib_detected == THD_LIB_LT ? SIGALRM : SIGUSR1,
! 	      thread_alarm);
    }
    sigemptyset(&s);
    sigaddset(&s, THR_SERVER_ALARM);
    alarm_thread=pthread_self();
***************
*** 108,120 ****
    }
  #elif defined(USE_ONE_SIGNAL_HAND)
    pthread_sigmask(SIG_BLOCK, &s, NULL);		/* used with sigwait() */
! #if THR_SERVER_ALARM == THR_CLIENT_ALARM
!   sigset(THR_CLIENT_ALARM,process_alarm);	/* Linuxthreads */
!   pthread_sigmask(SIG_UNBLOCK, &s, NULL);
! #endif
  #else
    pthread_sigmask(SIG_UNBLOCK, &s, NULL);
-   sigset(THR_SERVER_ALARM,process_alarm);
  #endif
    DBUG_VOID_RETURN;
  }
--- 101,115 ----
    }
  #elif defined(USE_ONE_SIGNAL_HAND)
    pthread_sigmask(SIG_BLOCK, &s, NULL);		/* used with sigwait() */
!   if (thd_lib_detected == THD_LIB_LT)
!   {
!     my_sigset(thd_lib_detected == THD_LIB_LT ? SIGALRM : SIGUSR1,
!               process_alarm);        /* Linuxthreads */
!     pthread_sigmask(SIG_UNBLOCK, &s, NULL);
!   }
  #else
+   my_sigset(THR_SERVER_ALARM, process_alarm);
    pthread_sigmask(SIG_UNBLOCK, &s, NULL);
  #endif
    DBUG_VOID_RETURN;
  }
***************
*** 240,246 ****
        if (alarm_data->malloced)
  	my_free((gptr) alarm_data,MYF(0));
        found++;
! #ifndef DBUG_OFF
        break;
  #endif
      }
--- 235,241 ----
        if (alarm_data->malloced)
  	my_free((gptr) alarm_data,MYF(0));
        found++;
! #ifdef DBUG_OFF
        break;
  #endif
      }
***************
*** 249,258 ****
    if (!found)
    {
      if (*alarmed)
!       fprintf(stderr,"Warning: Didn't find alarm %lx in queue of %d alarms\n",
! 	      (long) *alarmed, alarm_queue.elements);
!     DBUG_PRINT("warning",("Didn't find alarm %lx in queue\n",
! 			  (long) *alarmed));
    }
    pthread_mutex_unlock(&LOCK_alarm);
    pthread_sigmask(SIG_SETMASK,&old_mask,NULL);
--- 244,254 ----
    if (!found)
    {
      if (*alarmed)
!       fprintf(stderr,
!               "Warning: Didn't find alarm 0x%lx in queue of %d alarms\n",
!               (long) *alarmed, alarm_queue.elements);
!     DBUG_PRINT("warning",("Didn't find alarm 0x%lx in queue\n",
!                          (long) *alarmed));
    }
    pthread_mutex_unlock(&LOCK_alarm);
    pthread_sigmask(SIG_SETMASK,&old_mask,NULL);
***************
*** 274,291 ****
    This must be first as we can't call DBUG inside an alarm for a normal thread
  */
  
! #if THR_SERVER_ALARM == THR_CLIENT_ALARM
!   if (!pthread_equal(pthread_self(),alarm_thread))
    {
  #if defined(MAIN) && !defined(__bsdi__)
!     printf("thread_alarm\n"); fflush(stdout);
  #endif
  #ifdef DONT_REMEMBER_SIGNAL
!     sigset(THR_CLIENT_ALARM,process_alarm);	/* int. thread system calls */
  #endif
      return;
    }
- #endif
  
    /*
      We have to do do the handling of the alarm in a sub function,
--- 270,287 ----
    This must be first as we can't call DBUG inside an alarm for a normal thread
  */
  
!   if (thd_lib_detected == THD_LIB_LT &&
!       !pthread_equal(pthread_self(),alarm_thread))
    {
  #if defined(MAIN) && !defined(__bsdi__)
!     printf("thread_alarm in process_alarm\n"); fflush(stdout);
  #endif
  #ifdef DONT_REMEMBER_SIGNAL
!     my_sigset(thd_lib_detected == THD_LIB_LT ? SIGALRM : SIGUSR1,
!               process_alarm);	/* int. thread system calls */
  #endif
      return;
    }
  
    /*
      We have to do do the handling of the alarm in a sub function,
***************
*** 301,307 ****
    process_alarm_part2(sig);
  #ifndef USE_ALARM_THREAD
  #if defined(DONT_REMEMBER_SIGNAL) && !defined(USE_ONE_SIGNAL_HAND)
!   sigset(THR_SERVER_ALARM,process_alarm);
  #endif
    pthread_mutex_unlock(&LOCK_alarm);
    pthread_sigmask(SIG_SETMASK,&old_mask,NULL);
--- 297,303 ----
    process_alarm_part2(sig);
  #ifndef USE_ALARM_THREAD
  #if defined(DONT_REMEMBER_SIGNAL) && !defined(USE_ONE_SIGNAL_HAND)
!   my_sigset(THR_SERVER_ALARM, process_alarm);
  #endif
    pthread_mutex_unlock(&LOCK_alarm);
    pthread_sigmask(SIG_SETMASK,&old_mask,NULL);
***************
*** 504,520 ****
    ARGSUSED
  */
  
- #if THR_CLIENT_ALARM != SIGALRM || defined(USE_ALARM_THREAD)
  static sig_handler thread_alarm(int sig)
  {
  #ifdef MAIN
    printf("thread_alarm\n"); fflush(stdout);
  #endif
  #ifdef DONT_REMEMBER_SIGNAL
!   sigset(sig,thread_alarm);		/* int. thread system calls */
  #endif
  }
- #endif
  
  
  #ifdef HAVE_TIMESPEC_TS_SEC
--- 499,513 ----
    ARGSUSED
  */
  
  static sig_handler thread_alarm(int sig)
  {
  #ifdef MAIN
    printf("thread_alarm\n"); fflush(stdout);
  #endif
  #ifdef DONT_REMEMBER_SIGNAL
!   my_sigset(sig, thread_alarm);		/* int. thread system calls */
  #endif
  }
  
  
  #ifdef HAVE_TIMESPEC_TS_SEC
***************
*** 915,921 ****
    printf("Warning: Got signal %d from thread %s\n",sig,my_thread_name());
    fflush(stdout);
  #ifdef DONT_REMEMBER_SIGNAL
!   sigset(sig,print_signal_warning);		/* int. thread system calls */
  #endif
  #ifndef OS2
    if (sig == SIGALRM)
--- 908,914 ----
    printf("Warning: Got signal %d from thread %s\n",sig,my_thread_name());
    fflush(stdout);
  #ifdef DONT_REMEMBER_SIGNAL
!   my_sigset(sig, print_signal_warning);         /* int. thread system calls */
  #endif
  #ifndef OS2
    if (sig == SIGALRM)