eina_debug_timer code convention

This commit is contained in:
carlos 2020-04-17 11:38:13 -03:00 committed by João Paulo Taylor Ienczak Zanette
parent 1b3f60780e
commit 4cee97de7e
1 changed files with 35 additions and 38 deletions

View File

@ -78,7 +78,7 @@ end:
if (!t2) _timers = eina_list_append(_timers, t); if (!t2) _timers = eina_list_append(_timers, t);
else _timers = eina_list_prepend_relative(_timers, t, t2); else _timers = eina_list_prepend_relative(_timers, t, t2);
if (write(pipeToThread[1], &c, 1) != 1) if (write(pipeToThread[1], &c, 1) != 1)
e_debug("EINA DEBUG ERROR: Can't wake up thread for debug timer"); e_debug("EINA DEBUG ERROR: Can't wake up thread for debug timer");
} }
static void * static void *
@ -159,35 +159,34 @@ eina_debug_timer_add(unsigned int timeout_ms, Eina_Debug_Timer_Cb cb, void *data
eina_spinlock_take(&_lock); eina_spinlock_take(&_lock);
_timer_append(t); _timer_append(t);
if (!_thread_runs) if (!_thread_runs)
{ {
#ifndef _WIN32 #ifndef _WIN32
sigset_t oldset, newset; sigset_t oldset, newset;
sigemptyset(&newset);
sigemptyset(&newset); sigaddset(&newset, SIGPIPE);
sigaddset(&newset, SIGPIPE); sigaddset(&newset, SIGALRM);
sigaddset(&newset, SIGALRM); sigaddset(&newset, SIGCHLD);
sigaddset(&newset, SIGCHLD); sigaddset(&newset, SIGUSR1);
sigaddset(&newset, SIGUSR1); sigaddset(&newset, SIGUSR2);
sigaddset(&newset, SIGUSR2); sigaddset(&newset, SIGHUP);
sigaddset(&newset, SIGHUP); sigaddset(&newset, SIGQUIT);
sigaddset(&newset, SIGQUIT); sigaddset(&newset, SIGINT);
sigaddset(&newset, SIGINT); sigaddset(&newset, SIGTERM);
sigaddset(&newset, SIGTERM); # ifdef SIGPWR
# ifdef SIGPWR sigaddset(&newset, SIGPWR);
sigaddset(&newset, SIGPWR); # endif
# endif pthread_sigmask(SIG_BLOCK, &newset, &oldset);
pthread_sigmask(SIG_BLOCK, &newset, &oldset); #endif
#endif int err = eina_thread_create(&_thread, NULL, _monitor, NULL);
int err = pthread_create(&_thread, NULL, _monitor, NULL); #ifndef _WIN32
#ifndef _WIN32 pthread_sigmask(SIG_SETMASK, &oldset, NULL);
pthread_sigmask(SIG_SETMASK, &oldset, NULL); #endif
#endif if (!err)
if (err != 0) {
{ e_debug("EINA DEBUG ERROR: Can't create debug timer thread!");
e_debug("EINA DEBUG ERROR: Can't create debug timer thread!"); abort();
abort(); }
} _thread_runs = EINA_TRUE;
_thread_runs = EINA_TRUE;
} }
eina_spinlock_release(&_lock); eina_spinlock_release(&_lock);
return t; return t;
@ -199,10 +198,10 @@ eina_debug_timer_del(Eina_Debug_Timer *t)
eina_spinlock_take(&_lock); eina_spinlock_take(&_lock);
Eina_List *itr = eina_list_data_find_list(_timers, t); Eina_List *itr = eina_list_data_find_list(_timers, t);
if (itr) if (itr)
{ {
_timers = eina_list_remove_list(_timers, itr); _timers = eina_list_remove_list(_timers, itr);
free(t); free(t);
} }
eina_spinlock_release(&_lock); eina_spinlock_release(&_lock);
} }
@ -211,8 +210,7 @@ _eina_debug_timer_init(void)
{ {
eina_spinlock_new(&_lock); eina_spinlock_new(&_lock);
#ifndef _WIN32 #ifndef _WIN32
if (pipe(pipeToThread) == -1) if (pipe(pipeToThread) == -1) return EINA_FALSE;
return EINA_FALSE;
#endif #endif
return EINA_TRUE; return EINA_TRUE;
} }
@ -227,8 +225,7 @@ _eina_debug_timer_shutdown(void)
free(t); free(t);
close(pipeToThread[0]); close(pipeToThread[0]);
close(pipeToThread[1]); close(pipeToThread[1]);
if (_thread_runs) if (_thread_runs) eina_thread_cancel(_thread);
eina_thread_cancel(_thread);
_thread_runs = 0; _thread_runs = 0;
eina_spinlock_release(&_lock); eina_spinlock_release(&_lock);
eina_spinlock_free(&_lock); eina_spinlock_free(&_lock);