Browse Source

Revert "Change get_work to use a timeout when trying to tq_pop as a sanity failsafe in case of unusual circumstances."

This reverts commit 7b9b078114.

Conflicts:

	util.c

Timeout was a bandaid for other going-idle reasons and never helped. Revert it.
nfactor-troky
Con Kolivas 14 years ago
parent
commit
579bd42919
  1. 13
      main.c
  2. 5
      util.c

13
main.c

@ -1225,8 +1225,6 @@ static void flush_requests(bool longpoll)
static bool get_work(struct work *work, bool queued) static bool get_work(struct work *work, bool queued)
{ {
struct timeval now;
struct timespec abstime = {};
struct thr_info *thr = &thr_info[0]; struct thr_info *thr = &thr_info[0];
struct work *work_heap; struct work *work_heap;
bool ret = false; bool ret = false;
@ -1235,9 +1233,6 @@ static bool get_work(struct work *work, bool queued)
getwork_requested++; getwork_requested++;
retry: retry:
gettimeofday(&now, NULL);
abstime.tv_sec = now.tv_sec + 60;
if (unlikely(!queued && !queue_request())) { if (unlikely(!queued && !queue_request())) {
applog(LOG_WARNING, "Failed to queue_request in get_work"); applog(LOG_WARNING, "Failed to queue_request in get_work");
goto out; goto out;
@ -1265,12 +1260,10 @@ retry:
applog(LOG_WARNING, "Resumed retrieving work from server"); applog(LOG_WARNING, "Resumed retrieving work from server");
} }
/* Wait for 1st response, or get cached response. We really should /* wait for 1st response, or get cached response */
* never time out on the pop request but something might go amiss :/ work_heap = tq_pop(thr->q, NULL);
*/
work_heap = tq_pop(thr->q, &abstime);
if (unlikely(!work_heap)) { if (unlikely(!work_heap)) {
applog(LOG_INFO, "Failed to tq_pop in get_work"); applog(LOG_WARNING, "Failed to tq_pop in get_work");
goto out; goto out;
} }
dec_queued(); dec_queued();

5
util.c

@ -573,11 +573,8 @@ void *tq_pop(struct thread_q *tq, const struct timespec *abstime)
rc = pthread_cond_timedwait(&tq->cond, &tq->mutex, abstime); rc = pthread_cond_timedwait(&tq->cond, &tq->mutex, abstime);
else else
rc = pthread_cond_wait(&tq->cond, &tq->mutex); rc = pthread_cond_wait(&tq->cond, &tq->mutex);
if (unlikely(rc)) { if (rc)
if (rc == ETIMEDOUT)
applog(LOG_WARNING, "Timed out waiting in tq_pop");
goto out; goto out;
}
if (list_empty(&tq->q)) if (list_empty(&tq->q))
goto out; goto out;

Loading…
Cancel
Save