203
static int init(drizzled::plugin::Registry&)
203
class SignalHandler :
204
public drizzled::plugin::Daemon
206
pthread_attr_t thr_attr;
207
size_t my_thread_stack_size= 65536;
209
(void) pthread_attr_init(&thr_attr);
210
pthread_attr_setscope(&thr_attr, PTHREAD_SCOPE_SYSTEM);
211
(void) pthread_attr_setdetachstate(&thr_attr, PTHREAD_CREATE_DETACHED);
206
SignalHandler(const SignalHandler &);
207
SignalHandler& operator=(const SignalHandler &);
210
: drizzled::plugin::Daemon("Signal Handler")
213
struct sched_param tmp_sched_param;
215
memset(&tmp_sched_param, 0, sizeof(tmp_sched_param));
216
tmp_sched_param.sched_priority= INTERRUPT_PRIOR;
217
(void)pthread_attr_setschedparam(&thr_attr, &tmp_sched_param);
213
pthread_attr_t thr_attr;
214
size_t my_thread_stack_size= 65536;
216
(void) pthread_attr_init(&thr_attr);
217
pthread_attr_setscope(&thr_attr, PTHREAD_SCOPE_SYSTEM);
218
(void) pthread_attr_setdetachstate(&thr_attr, PTHREAD_CREATE_DETACHED);
220
struct sched_param tmp_sched_param;
222
memset(&tmp_sched_param, 0, sizeof(tmp_sched_param));
223
tmp_sched_param.sched_priority= INTERRUPT_PRIOR;
224
(void)pthread_attr_setschedparam(&thr_attr, &tmp_sched_param);
219
226
#if defined(__ia64__) || defined(__ia64)
221
Peculiar things with ia64 platforms - it seems we only have half the
222
stack size in reality, so we have to double it here
224
pthread_attr_setstacksize(&thr_attr, my_thread_stack_size*2);
228
Peculiar things with ia64 platforms - it seems we only have half the
229
stack size in reality, so we have to double it here
231
pthread_attr_setstacksize(&thr_attr, my_thread_stack_size*2);
226
pthread_attr_setstacksize(&thr_attr, my_thread_stack_size);
233
pthread_attr_setstacksize(&thr_attr, my_thread_stack_size);
229
(void) pthread_mutex_lock(&LOCK_thread_count);
230
if ((error=pthread_create(&signal_thread, &thr_attr, signal_hand, 0)))
232
errmsg_printf(ERRMSG_LVL_ERROR, _("Can't create interrupt-thread (error %d, errno: %d)"),
236
(void) pthread_mutex_lock(&LOCK_thread_count);
237
if ((error=pthread_create(&signal_thread, &thr_attr, signal_hand, 0)))
239
errmsg_printf(ERRMSG_LVL_ERROR,
240
_("Can't create interrupt-thread (error %d, errno: %d)"),
244
(void) pthread_cond_wait(&COND_thread_count,&LOCK_thread_count);
245
pthread_mutex_unlock(&LOCK_thread_count);
247
(void) pthread_attr_destroy(&thr_attr);
236
(void) pthread_cond_wait(&COND_thread_count,&LOCK_thread_count);
237
pthread_mutex_unlock(&LOCK_thread_count);
239
(void) pthread_attr_destroy(&thr_attr);
245
This is mainly needed when running with purify, but it's still nice to
246
know that all child threads have died when drizzled exits.
248
static int deinit(drizzled::plugin::Registry&)
252
Wait up to 10 seconds for signal thread to die. We use this mainly to
253
avoid getting warnings that internal::my_thread_end has not been called
251
This is mainly needed when running with purify, but it's still nice to
252
know that all child threads have died when drizzled exits.
255
for (i= 0 ; i < 100 && signal_thread_in_use; i++)
257
if (pthread_kill(signal_thread, SIGTERM) != ESRCH)
259
usleep(100); // Give it time to die
258
Wait up to 10 seconds for signal thread to die. We use this mainly to
259
avoid getting warnings that internal::my_thread_end has not been called
261
for (i= 0 ; i < 100 && signal_thread_in_use; i++)
263
if (pthread_kill(signal_thread, SIGTERM) != ESRCH)
265
usleep(100); // Give it time to die
271
static int init(drizzled::plugin::Context& context)
273
SignalHandler *handler= new SignalHandler;
274
context.add(handler);
265
279
static drizzle_sys_var* system_variables[]= {