summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcarlos <caiosignor@gmail.com>2020-04-17 11:38:13 -0300
committerJoão Paulo Taylor Ienczak Zanette <jpaulotiz@gmail.com>2020-04-29 12:13:38 -0300
commit4cee97de7e1becb523ccf70bab60241ec4404cf2 (patch)
treeadc95c2bdc09eea0fa4aef95017a09c2e4881ab4
parent1b3f60780e83716e4233e8e7db6f52ecc7c36a8a (diff)
eina_debug_timer code convention
-rw-r--r--src/lib/eina/eina_debug_timer.c73
1 files changed, 35 insertions, 38 deletions
diff --git a/src/lib/eina/eina_debug_timer.c b/src/lib/eina/eina_debug_timer.c
index e498251ca2..218f883e60 100644
--- a/src/lib/eina/eina_debug_timer.c
+++ b/src/lib/eina/eina_debug_timer.c
@@ -78,7 +78,7 @@ end:
78 if (!t2) _timers = eina_list_append(_timers, t); 78 if (!t2) _timers = eina_list_append(_timers, t);
79 else _timers = eina_list_prepend_relative(_timers, t, t2); 79 else _timers = eina_list_prepend_relative(_timers, t, t2);
80 if (write(pipeToThread[1], &c, 1) != 1) 80 if (write(pipeToThread[1], &c, 1) != 1)
81 e_debug("EINA DEBUG ERROR: Can't wake up thread for debug timer"); 81 e_debug("EINA DEBUG ERROR: Can't wake up thread for debug timer");
82} 82}
83 83
84static void * 84static void *
@@ -159,35 +159,34 @@ eina_debug_timer_add(unsigned int timeout_ms, Eina_Debug_Timer_Cb cb, void *data
159 eina_spinlock_take(&_lock); 159 eina_spinlock_take(&_lock);
160 _timer_append(t); 160 _timer_append(t);
161 if (!_thread_runs) 161 if (!_thread_runs)
162 { 162 {
163#ifndef _WIN32 163 #ifndef _WIN32
164 sigset_t oldset, newset; 164 sigset_t oldset, newset;
165 165 sigemptyset(&newset);
166 sigemptyset(&newset); 166 sigaddset(&newset, SIGPIPE);
167 sigaddset(&newset, SIGPIPE); 167 sigaddset(&newset, SIGALRM);
168 sigaddset(&newset, SIGALRM); 168 sigaddset(&newset, SIGCHLD);
169 sigaddset(&newset, SIGCHLD); 169 sigaddset(&newset, SIGUSR1);
170 sigaddset(&newset, SIGUSR1); 170 sigaddset(&newset, SIGUSR2);
171 sigaddset(&newset, SIGUSR2); 171 sigaddset(&newset, SIGHUP);
172 sigaddset(&newset, SIGHUP); 172 sigaddset(&newset, SIGQUIT);
173 sigaddset(&newset, SIGQUIT); 173 sigaddset(&newset, SIGINT);
174 sigaddset(&newset, SIGINT); 174 sigaddset(&newset, SIGTERM);
175 sigaddset(&newset, SIGTERM); 175 # ifdef SIGPWR
176# ifdef SIGPWR 176 sigaddset(&newset, SIGPWR);
177 sigaddset(&newset, SIGPWR); 177 # endif
178# endif 178 pthread_sigmask(SIG_BLOCK, &newset, &oldset);
179 pthread_sigmask(SIG_BLOCK, &newset, &oldset); 179 #endif
180#endif 180 int err = eina_thread_create(&_thread, NULL, _monitor, NULL);
181 int err = pthread_create(&_thread, NULL, _monitor, NULL); 181 #ifndef _WIN32
182#ifndef _WIN32 182 pthread_sigmask(SIG_SETMASK, &oldset, NULL);
183 pthread_sigmask(SIG_SETMASK, &oldset, NULL); 183 #endif
184#endif 184 if (!err)
185 if (err != 0) 185 {
186 { 186 e_debug("EINA DEBUG ERROR: Can't create debug timer thread!");
187 e_debug("EINA DEBUG ERROR: Can't create debug timer thread!"); 187 abort();
188 abort(); 188 }
189 } 189 _thread_runs = EINA_TRUE;
190 _thread_runs = EINA_TRUE;
191 } 190 }
192 eina_spinlock_release(&_lock); 191 eina_spinlock_release(&_lock);
193 return t; 192 return t;
@@ -199,10 +198,10 @@ eina_debug_timer_del(Eina_Debug_Timer *t)
199 eina_spinlock_take(&_lock); 198 eina_spinlock_take(&_lock);
200 Eina_List *itr = eina_list_data_find_list(_timers, t); 199 Eina_List *itr = eina_list_data_find_list(_timers, t);
201 if (itr) 200 if (itr)
202 { 201 {
203 _timers = eina_list_remove_list(_timers, itr); 202 _timers = eina_list_remove_list(_timers, itr);
204 free(t); 203 free(t);
205 } 204 }
206 eina_spinlock_release(&_lock); 205 eina_spinlock_release(&_lock);
207} 206}
208 207
@@ -211,8 +210,7 @@ _eina_debug_timer_init(void)
211{ 210{
212 eina_spinlock_new(&_lock); 211 eina_spinlock_new(&_lock);
213#ifndef _WIN32 212#ifndef _WIN32
214 if (pipe(pipeToThread) == -1) 213 if (pipe(pipeToThread) == -1) return EINA_FALSE;
215 return EINA_FALSE;
216#endif 214#endif
217 return EINA_TRUE; 215 return EINA_TRUE;
218} 216}
@@ -227,8 +225,7 @@ _eina_debug_timer_shutdown(void)
227 free(t); 225 free(t);
228 close(pipeToThread[0]); 226 close(pipeToThread[0]);
229 close(pipeToThread[1]); 227 close(pipeToThread[1]);
230 if (_thread_runs) 228 if (_thread_runs) eina_thread_cancel(_thread);
231 eina_thread_cancel(_thread);
232 _thread_runs = 0; 229 _thread_runs = 0;
233 eina_spinlock_release(&_lock); 230 eina_spinlock_release(&_lock);
234 eina_spinlock_free(&_lock); 231 eina_spinlock_free(&_lock);