mirror of
https://github.com/Llewellynvdm/conky.git
synced 2024-09-30 05:59:07 +00:00
Handle thread death better (sf.net #2818145).
This commit is contained in:
parent
18ecbef1ae
commit
ce19f6ee6a
@ -47,6 +47,7 @@ struct _timed_thread {
|
||||
struct timespec interval_time; /* interval_usecs as a struct timespec */
|
||||
struct timespec wait_time; /* absolute future time next timed_thread_test will wait until */
|
||||
int pipefd[2];
|
||||
int die;
|
||||
};
|
||||
|
||||
/* linked list of created threads */
|
||||
@ -156,6 +157,7 @@ void timed_thread_destroy(timed_thread *p_timed_thread,
|
||||
/* signal thread to stop */
|
||||
pthread_mutex_lock(&p_timed_thread->runnable_mutex);
|
||||
pthread_cond_signal(&p_timed_thread->runnable_cond);
|
||||
p_timed_thread->die = 1;
|
||||
pthread_mutex_unlock(&p_timed_thread->runnable_mutex);
|
||||
write(p_timed_thread->pipefd[1], "die", 3);
|
||||
|
||||
@ -209,6 +211,11 @@ int timed_thread_test(timed_thread *p_timed_thread, int override_wait_time)
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (p_timed_thread->die) {
|
||||
/* if we were kindly asked to die, then die */
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (override_wait_time && now(&p_timed_thread->wait_time)) {
|
||||
return -1;
|
||||
}
|
||||
|
@ -46,7 +46,8 @@ int timed_thread_lock(timed_thread *p_timed_thread);
|
||||
int timed_thread_unlock(timed_thread *p_timed_thread);
|
||||
|
||||
/* waits required interval (unless override_wait_time is non-zero) for
|
||||
* termination signal returns 1 if received, 0 otherwise. */
|
||||
* termination signal returns 1 if received, 0 otherwise. should also return 1
|
||||
* if the thread has been asked kindly to die. */
|
||||
int timed_thread_test(timed_thread *p_timed_thread, int override_wait_time);
|
||||
|
||||
/* exit a timed thread */
|
||||
|
Loading…
Reference in New Issue
Block a user