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
|
2008-12-08
|
||||||
* Fix runtime debugging macros again
|
* Fix runtime debugging macros again
|
||||||
* Big hddtemp rewrite
|
* Big hddtemp rewrite
|
||||||
|
@ -1851,7 +1851,7 @@ void *imap_thread(void *arg)
|
|||||||
FD_SET(sockfd, &fdset);
|
FD_SET(sockfd, &fdset);
|
||||||
FD_SET(threadfd, &fdset);
|
FD_SET(threadfd, &fdset);
|
||||||
res = select(MAX(sockfd + 1, threadfd + 1), &fdset, NULL, NULL, NULL);
|
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 ((fstat(sockfd, &stat_buf) == 0) && S_ISSOCK(stat_buf.st_mode)) {
|
||||||
/* if a valid socket, close it */
|
/* if a valid socket, close it */
|
||||||
close(sockfd);
|
close(sockfd);
|
||||||
@ -1975,7 +1975,7 @@ void *imap_thread(void *arg)
|
|||||||
/* if a valid socket, close it */
|
/* if a valid socket, close it */
|
||||||
close(sockfd);
|
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);
|
timed_thread_exit(mail->p_timed_thread);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2148,7 +2148,7 @@ void *pop3_thread(void *arg)
|
|||||||
/* if a valid socket, close it */
|
/* if a valid socket, close it */
|
||||||
close(sockfd);
|
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);
|
timed_thread_exit(mail->p_timed_thread);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2188,7 +2188,7 @@ void *threaded_exec(void *arg)
|
|||||||
p2++;
|
p2++;
|
||||||
}
|
}
|
||||||
timed_thread_unlock(obj->data.texeci.p_timed_thread);
|
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);
|
timed_thread_exit(obj->data.texeci.p_timed_thread);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -103,7 +103,7 @@ void *update_moc(void *arg)
|
|||||||
timed_thread_lock(moc->timed_thread);
|
timed_thread_lock(moc->timed_thread);
|
||||||
update_infos(moc);
|
update_infos(moc);
|
||||||
timed_thread_unlock(moc->timed_thread);
|
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);
|
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",
|
strncpy(mpd->status, "MPD not responding",
|
||||||
text_buffer_size - 1);
|
text_buffer_size - 1);
|
||||||
timed_thread_unlock(mpd->timed_thread);
|
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);
|
timed_thread_exit(mpd->timed_thread);
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
@ -171,7 +171,7 @@ void *update_mpd(void *arg)
|
|||||||
strncpy(mpd->status, "MPD not responding",
|
strncpy(mpd->status, "MPD not responding",
|
||||||
text_buffer_size - 1);
|
text_buffer_size - 1);
|
||||||
timed_thread_unlock(mpd->timed_thread);
|
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);
|
timed_thread_exit(mpd->timed_thread);
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
@ -182,7 +182,7 @@ void *update_mpd(void *arg)
|
|||||||
mpd_closeConnection(mpd->conn);
|
mpd_closeConnection(mpd->conn);
|
||||||
mpd->conn = 0;
|
mpd->conn = 0;
|
||||||
timed_thread_unlock(mpd->timed_thread);
|
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);
|
timed_thread_exit(mpd->timed_thread);
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
@ -236,7 +236,7 @@ void *update_mpd(void *arg)
|
|||||||
mpd_closeConnection(mpd->conn);
|
mpd_closeConnection(mpd->conn);
|
||||||
mpd->conn = 0;
|
mpd->conn = 0;
|
||||||
timed_thread_unlock(mpd->timed_thread);
|
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);
|
timed_thread_exit(mpd->timed_thread);
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
@ -302,7 +302,7 @@ void *update_mpd(void *arg)
|
|||||||
mpd_closeConnection(mpd->conn);
|
mpd_closeConnection(mpd->conn);
|
||||||
mpd->conn = 0;
|
mpd->conn = 0;
|
||||||
timed_thread_unlock(mpd->timed_thread);
|
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);
|
timed_thread_exit(mpd->timed_thread);
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
@ -313,7 +313,7 @@ void *update_mpd(void *arg)
|
|||||||
// fprintf(stderr, "%s\n", mpd->conn->errorStr);
|
// fprintf(stderr, "%s\n", mpd->conn->errorStr);
|
||||||
mpd_closeConnection(mpd->conn);
|
mpd_closeConnection(mpd->conn);
|
||||||
mpd->conn = 0;
|
mpd->conn = 0;
|
||||||
if (timed_thread_test(mpd->timed_thread)) {
|
if (timed_thread_test(mpd->timed_thread, 0)) {
|
||||||
timed_thread_exit(mpd->timed_thread);
|
timed_thread_exit(mpd->timed_thread);
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
@ -324,7 +324,7 @@ void *update_mpd(void *arg)
|
|||||||
mpd_closeConnection(mpd->conn);
|
mpd_closeConnection(mpd->conn);
|
||||||
mpd->conn = 0;
|
mpd->conn = 0;
|
||||||
} */
|
} */
|
||||||
if (timed_thread_test(mpd->timed_thread)) {
|
if (timed_thread_test(mpd->timed_thread, 0)) {
|
||||||
timed_thread_exit(mpd->timed_thread);
|
timed_thread_exit(mpd->timed_thread);
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
|
@ -197,7 +197,7 @@ int timed_thread_unlock(timed_thread *p_timed_thread)
|
|||||||
/* thread waits interval_usecs for runnable_cond to be signaled.
|
/* thread waits interval_usecs for runnable_cond to be signaled.
|
||||||
* returns 1 if signaled, -1 on error, and 0 otherwise.
|
* returns 1 if signaled, -1 on error, and 0 otherwise.
|
||||||
* caller should call timed_thread_exit() on any non-zero return value. */
|
* 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;
|
struct timespec now_time;
|
||||||
int rc;
|
int rc;
|
||||||
@ -211,6 +211,10 @@ int timed_thread_test(timed_thread *p_timed_thread)
|
|||||||
return -1;
|
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 */
|
/* release mutex and wait until future time for runnable_cond to signal */
|
||||||
rc = pthread_cond_timedwait(&p_timed_thread->runnable_cond,
|
rc = pthread_cond_timedwait(&p_timed_thread->runnable_cond,
|
||||||
&p_timed_thread->runnable_mutex, &p_timed_thread->wait_time);
|
&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 */
|
/* unlock a timed thread after critical section activity */
|
||||||
int timed_thread_unlock(timed_thread *p_timed_thread);
|
int timed_thread_unlock(timed_thread *p_timed_thread);
|
||||||
|
|
||||||
/* waits required interval for termination signal
|
/* waits required interval (unless override_wait_time is non-zero) for
|
||||||
* returns 1 if received,
|
* termination signal returns 1 if received, 0 otherwise. */
|
||||||
* 0 otherwise */
|
int timed_thread_test(timed_thread *p_timed_thread, int override_wait_time);
|
||||||
int timed_thread_test(timed_thread *p_timed_thread);
|
|
||||||
|
|
||||||
/* exit a timed thread */
|
/* exit a timed thread */
|
||||||
void timed_thread_exit(timed_thread *p_timed_thread) __attribute__((noreturn));
|
void timed_thread_exit(timed_thread *p_timed_thread) __attribute__((noreturn));
|
||||||
|
Loading…
Reference in New Issue
Block a user