ecore: immediately block animator ticking upon receiving an exit signal

Summary:
when an exit (SIGINT, SIGQUIT, SIGTERM) signal is received, the ui should
immediately stop updating in order to present the user with an instant
response

this uses a simple volatile int to block any ticks which begin after the
signal is received; if a signal is received during a tick then it will complete
normally

fix T7000
Depends on D6589

Reviewers: ManMower

Reviewed By: ManMower

Subscribers: cedric, #committers

Tags: #efl_main_loop

Maniphest Tasks: T7000

Differential Revision: https://phab.enlightenment.org/D6590
This commit is contained in:
Mike Blumenkrantz 2018-07-13 15:40:55 -04:00
parent dab2a9ca68
commit 6405a5a68c
2 changed files with 16 additions and 2 deletions

View File

@ -110,6 +110,8 @@ static Eina_Spinlock tick_queue_lock;
static int tick_queue_count = 0;
static Eina_Bool tick_skip = EINA_FALSE;
extern volatile int exit_signal_received;
static void
_tick_send(signed char val)
{
@ -367,7 +369,7 @@ _timer_tick_notify(void *data EINA_UNUSED, Ecore_Thread *thread EINA_UNUSED, voi
if ((!tick_skip) || (tick_queued == 1))
{
ecore_loop_time_set(*t);
_do_tick();
if (!exit_signal_received) _do_tick();
_ecore_animator_flush();
}
pt = *t;
@ -935,7 +937,7 @@ ecore_animator_custom_tick(void)
{
EINA_MAIN_LOOP_CHECK_RETURN;
if (src != ECORE_ANIMATOR_SOURCE_CUSTOM) return;
_do_tick();
if (!exit_signal_received) _do_tick();
_ecore_animator_flush();
}

View File

@ -39,6 +39,8 @@ static Eo *sig_pipe_handler = NULL;
static Eina_Spinlock sig_pid_lock;
static Eina_List *sig_pid_info_list = NULL;
volatile int exit_signal_received = 0;
typedef struct _Signal_Data
{
int sig;
@ -171,6 +173,15 @@ _ecore_signal_callback(int sig, siginfo_t *si, void *foo EINA_UNUSED)
}
errno = err;
}
switch (sig)
{
case SIGQUIT:
case SIGINT:
case SIGTERM:
exit_signal_received = 1;
break;
default: break;
}
}
static void
@ -302,6 +313,7 @@ _ecore_signal_shutdown(void)
# endif
pthread_sigmask(SIG_BLOCK, &newset, NULL);
#endif
exit_signal_received = 0;
}
void