There aren't many signal handlers that actually want to move automatically.
It's just causing accidental bugs when signal handlers are run in
unexpected ioloops.
lib_signals_deinit();
lib_signals_init();
- lib_signals_set_handler(SIGTERM, LIBSIG_FLAG_DELAYED,
- test_subprocess_signal, NULL);
- lib_signals_set_handler(SIGQUIT, LIBSIG_FLAG_DELAYED,
- test_subprocess_signal, NULL);
- lib_signals_set_handler(SIGINT, LIBSIG_FLAG_DELAYED,
- test_subprocess_signal, NULL);
+ lib_signals_set_handler(SIGTERM,
+ LIBSIG_FLAG_DELAYED | LIBSIG_FLAG_IOLOOP_AUTOMOVE,
+ test_subprocess_signal, NULL);
+ lib_signals_set_handler(SIGQUIT,
+ LIBSIG_FLAG_DELAYED | LIBSIG_FLAG_IOLOOP_AUTOMOVE,
+ test_subprocess_signal, NULL);
+ lib_signals_set_handler(SIGINT,
+ LIBSIG_FLAG_DELAYED | LIBSIG_FLAG_IOLOOP_AUTOMOVE,
+ test_subprocess_signal, NULL);
ret = func(context);
hash_table_create_direct(&child_pids, default_pool, 0);
- lib_signals_set_handler(SIGCHLD,
- LIBSIG_FLAGS_SAFE | LIBSIG_FLAG_NO_IOLOOP_AUTOMOVE,
+ lib_signals_set_handler(SIGCHLD, LIBSIG_FLAGS_SAFE,
sigchld_handler, NULL);
}
for (h = signal_handlers[sis[i].si_signo]; h != NULL;
h = h->next) {
if ((h->flags & LIBSIG_FLAG_DELAYED) == 0 ||
- (h->flags & LIBSIG_FLAG_NO_IOLOOP_AUTOMOVE) == 0)
+ (h->flags & LIBSIG_FLAG_IOLOOP_AUTOMOVE) != 0)
continue;
if (h->shadowed &&
h->current_ioloop != current_ioloop) {
context */
continue;
}
- if ((h->flags & LIBSIG_FLAG_NO_IOLOOP_AUTOMOVE) != 0 &&
+ if ((h->flags & LIBSIG_FLAG_IOLOOP_AUTOMOVE) == 0 &&
h->current_ioloop != current_ioloop) {
/* cannot run handler in current ioloop
(shadowed) */
for (h = signal_handlers[signo]; h != NULL; h = h->next) {
if (h->handler == handler && h->context == context) {
i_assert((h->flags & LIBSIG_FLAG_DELAYED) != 0);
- i_assert((h->flags & LIBSIG_FLAG_NO_IOLOOP_AUTOMOVE) != 0);
+ i_assert((h->flags & LIBSIG_FLAG_IOLOOP_AUTOMOVE) == 0);
h->current_ioloop = current_ioloop;
/* check whether we can now handle any shadowed delayed
signals */
LIBSIG_FLAG_DELAYED = 0x01,
/* Restart syscalls instead of having them fail with EINTR */
LIBSIG_FLAG_RESTART = 0x02,
- /* Don't automatically shift delayed signal handling for this signal
+ /* Automatically shift delayed signal handling for this signal
to a newly started ioloop. */
- LIBSIG_FLAG_NO_IOLOOP_AUTOMOVE = 0x04,
+ LIBSIG_FLAG_IOLOOP_AUTOMOVE = 0x04,
};
#define LIBSIG_FLAGS_SAFE (LIBSIG_FLAG_DELAYED | LIBSIG_FLAG_RESTART)
i_zero(&tctx);
lib_signals_init();
- lib_signals_set_handler(SIGALRM, LIBSIG_FLAGS_SAFE,
+ lib_signals_set_handler(SIGALRM,
+ LIBSIG_FLAGS_SAFE | LIBSIG_FLAG_IOLOOP_AUTOMOVE,
signal_handler_delayed, &tctx);
ioloop = io_loop_create();
ioloop = io_loop_create();
lib_signals_init();
- lib_signals_set_handler(SIGALRM, LIBSIG_FLAGS_SAFE,
+ lib_signals_set_handler(SIGALRM,
+ LIBSIG_FLAGS_SAFE | LIBSIG_FLAG_IOLOOP_AUTOMOVE,
signal_handler_delayed, &tctx);
to_kill = timeout_add_short(200, kill_timeout, &tctx);
i_zero(&tctx);
lib_signals_init();
- lib_signals_set_handler(SIGALRM, LIBSIG_FLAGS_SAFE,
+ lib_signals_set_handler(SIGALRM,
+ LIBSIG_FLAGS_SAFE | LIBSIG_FLAG_IOLOOP_AUTOMOVE,
signal_handler_delayed, &tctx);
/* briefly run outer ioloop */
ioloop1 = io_loop_create();
lib_signals_init();
- lib_signals_set_handler(SIGALRM,
- LIBSIG_FLAGS_SAFE | LIBSIG_FLAG_NO_IOLOOP_AUTOMOVE,
+ lib_signals_set_handler(SIGALRM, LIBSIG_FLAGS_SAFE,
signal_handler_delayed, &tctx);
/* briefly run outer ioloop */
ioloop1 = io_loop_create();
lib_signals_init();
- lib_signals_set_handler(SIGALRM,
- LIBSIG_FLAGS_SAFE | LIBSIG_FLAG_NO_IOLOOP_AUTOMOVE,
+ lib_signals_set_handler(SIGALRM, LIBSIG_FLAGS_SAFE,
signal_handler_delayed, &tctx);
/* briefly run outer ioloop */