mirror of
https://github.com/Llewellynvdm/conky.git
synced 2025-01-12 19:06:36 +00:00
Add an option to timed_thread_test() to not wait for the interval period (so that IMAP IDLE works better)
This commit is contained in:
parent
12b6e3ffef
commit
a40cfd9702
@ -1,3 +1,7 @@
|
||||
2008-12-09
|
||||
* Add an option to timed_thread_test() to not wait for the interval period
|
||||
(so that IMAP IDLE works better)
|
||||
|
||||
2008-12-08
|
||||
* Fix runtime debugging macros again
|
||||
* Big hddtemp rewrite
|
||||
|
@ -1851,7 +1851,7 @@ void *imap_thread(void *arg)
|
||||
FD_SET(sockfd, &fdset);
|
||||
FD_SET(threadfd, &fdset);
|
||||
res = select(MAX(sockfd + 1, threadfd + 1), &fdset, NULL, NULL, NULL);
|
||||
if (timed_thread_test(mail->p_timed_thread) || (res == -1 && errno == EINTR) || FD_ISSET(threadfd, &fdset)) {
|
||||
if (timed_thread_test(mail->p_timed_thread, 1) || (res == -1 && errno == EINTR) || FD_ISSET(threadfd, &fdset)) {
|
||||
if ((fstat(sockfd, &stat_buf) == 0) && S_ISSOCK(stat_buf.st_mode)) {
|
||||
/* if a valid socket, close it */
|
||||
close(sockfd);
|
||||
@ -1975,7 +1975,7 @@ void *imap_thread(void *arg)
|
||||
/* if a valid socket, close it */
|
||||
close(sockfd);
|
||||
}
|
||||
if (timed_thread_test(mail->p_timed_thread)) {
|
||||
if (timed_thread_test(mail->p_timed_thread, 0)) {
|
||||
timed_thread_exit(mail->p_timed_thread);
|
||||
}
|
||||
}
|
||||
@ -2148,7 +2148,7 @@ void *pop3_thread(void *arg)
|
||||
/* if a valid socket, close it */
|
||||
close(sockfd);
|
||||
}
|
||||
if (timed_thread_test(mail->p_timed_thread)) {
|
||||
if (timed_thread_test(mail->p_timed_thread, 0)) {
|
||||
timed_thread_exit(mail->p_timed_thread);
|
||||
}
|
||||
}
|
||||
@ -2188,7 +2188,7 @@ void *threaded_exec(void *arg)
|
||||
p2++;
|
||||
}
|
||||
timed_thread_unlock(obj->data.texeci.p_timed_thread);
|
||||
if (timed_thread_test(obj->data.texeci.p_timed_thread)) {
|
||||
if (timed_thread_test(obj->data.texeci.p_timed_thread, 0)) {
|
||||
timed_thread_exit(obj->data.texeci.p_timed_thread);
|
||||
}
|
||||
}
|
||||
|
@ -103,7 +103,7 @@ void *update_moc(void *arg)
|
||||
timed_thread_lock(moc->timed_thread);
|
||||
update_infos(moc);
|
||||
timed_thread_unlock(moc->timed_thread);
|
||||
if (timed_thread_test(moc->timed_thread)) {
|
||||
if (timed_thread_test(moc->timed_thread, 0)) {
|
||||
timed_thread_exit(moc->timed_thread);
|
||||
}
|
||||
}
|
||||
|
14
src/mpd.c
14
src/mpd.c
@ -155,7 +155,7 @@ void *update_mpd(void *arg)
|
||||
strncpy(mpd->status, "MPD not responding",
|
||||
text_buffer_size - 1);
|
||||
timed_thread_unlock(mpd->timed_thread);
|
||||
if (timed_thread_test(mpd->timed_thread)) {
|
||||
if (timed_thread_test(mpd->timed_thread, 0)) {
|
||||
timed_thread_exit(mpd->timed_thread);
|
||||
}
|
||||
continue;
|
||||
@ -171,7 +171,7 @@ void *update_mpd(void *arg)
|
||||
strncpy(mpd->status, "MPD not responding",
|
||||
text_buffer_size - 1);
|
||||
timed_thread_unlock(mpd->timed_thread);
|
||||
if (timed_thread_test(mpd->timed_thread)) {
|
||||
if (timed_thread_test(mpd->timed_thread, 0)) {
|
||||
timed_thread_exit(mpd->timed_thread);
|
||||
}
|
||||
continue;
|
||||
@ -182,7 +182,7 @@ void *update_mpd(void *arg)
|
||||
mpd_closeConnection(mpd->conn);
|
||||
mpd->conn = 0;
|
||||
timed_thread_unlock(mpd->timed_thread);
|
||||
if (timed_thread_test(mpd->timed_thread)) {
|
||||
if (timed_thread_test(mpd->timed_thread, 0)) {
|
||||
timed_thread_exit(mpd->timed_thread);
|
||||
}
|
||||
continue;
|
||||
@ -236,7 +236,7 @@ void *update_mpd(void *arg)
|
||||
mpd_closeConnection(mpd->conn);
|
||||
mpd->conn = 0;
|
||||
timed_thread_unlock(mpd->timed_thread);
|
||||
if (timed_thread_test(mpd->timed_thread)) {
|
||||
if (timed_thread_test(mpd->timed_thread, 0)) {
|
||||
timed_thread_exit(mpd->timed_thread);
|
||||
}
|
||||
continue;
|
||||
@ -302,7 +302,7 @@ void *update_mpd(void *arg)
|
||||
mpd_closeConnection(mpd->conn);
|
||||
mpd->conn = 0;
|
||||
timed_thread_unlock(mpd->timed_thread);
|
||||
if (timed_thread_test(mpd->timed_thread)) {
|
||||
if (timed_thread_test(mpd->timed_thread, 0)) {
|
||||
timed_thread_exit(mpd->timed_thread);
|
||||
}
|
||||
continue;
|
||||
@ -313,7 +313,7 @@ void *update_mpd(void *arg)
|
||||
// fprintf(stderr, "%s\n", mpd->conn->errorStr);
|
||||
mpd_closeConnection(mpd->conn);
|
||||
mpd->conn = 0;
|
||||
if (timed_thread_test(mpd->timed_thread)) {
|
||||
if (timed_thread_test(mpd->timed_thread, 0)) {
|
||||
timed_thread_exit(mpd->timed_thread);
|
||||
}
|
||||
continue;
|
||||
@ -324,7 +324,7 @@ void *update_mpd(void *arg)
|
||||
mpd_closeConnection(mpd->conn);
|
||||
mpd->conn = 0;
|
||||
} */
|
||||
if (timed_thread_test(mpd->timed_thread)) {
|
||||
if (timed_thread_test(mpd->timed_thread, 0)) {
|
||||
timed_thread_exit(mpd->timed_thread);
|
||||
}
|
||||
continue;
|
||||
|
@ -197,7 +197,7 @@ int timed_thread_unlock(timed_thread *p_timed_thread)
|
||||
/* thread waits interval_usecs for runnable_cond to be signaled.
|
||||
* returns 1 if signaled, -1 on error, and 0 otherwise.
|
||||
* caller should call timed_thread_exit() on any non-zero return value. */
|
||||
int timed_thread_test(timed_thread *p_timed_thread)
|
||||
int timed_thread_test(timed_thread *p_timed_thread, int override_wait_time)
|
||||
{
|
||||
struct timespec now_time;
|
||||
int rc;
|
||||
@ -211,6 +211,10 @@ int timed_thread_test(timed_thread *p_timed_thread)
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (override_wait_time && now(&p_timed_thread->wait_time)) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* release mutex and wait until future time for runnable_cond to signal */
|
||||
rc = pthread_cond_timedwait(&p_timed_thread->runnable_cond,
|
||||
&p_timed_thread->runnable_mutex, &p_timed_thread->wait_time);
|
||||
|
@ -47,10 +47,9 @@ int timed_thread_lock(timed_thread *p_timed_thread);
|
||||
/* unlock a timed thread after critical section activity */
|
||||
int timed_thread_unlock(timed_thread *p_timed_thread);
|
||||
|
||||
/* waits required interval for termination signal
|
||||
* returns 1 if received,
|
||||
* 0 otherwise */
|
||||
int timed_thread_test(timed_thread *p_timed_thread);
|
||||
/* waits required interval (unless override_wait_time is non-zero) for
|
||||
* termination signal returns 1 if received, 0 otherwise. */
|
||||
int timed_thread_test(timed_thread *p_timed_thread, int override_wait_time);
|
||||
|
||||
/* exit a timed thread */
|
||||
void timed_thread_exit(timed_thread *p_timed_thread) __attribute__((noreturn));
|
||||
|
Loading…
Reference in New Issue
Block a user