MT#55283 convert notify to int64_t

Change-Id: Ia30d935966d2dd33902ffee8c46ddd184444f829
pull/1855/merge
Richard Fuchs 2 weeks ago
parent 9018099467
commit a7d71f09b8

@ -11,7 +11,7 @@ struct notif_req {
struct curl_slist *headers; struct curl_slist *headers;
char *full_filename_path; char *full_filename_path;
time_t retry_time; int64_t retry_time;
unsigned int retries; unsigned int retries;
unsigned int falloff; unsigned int falloff;
}; };
@ -152,7 +152,7 @@ fail:
"Failed to create CURL object. Will retry in %u seconds (#%u)", "Failed to create CURL object. Will retry in %u seconds (#%u)",
FMT_M(req->name), FMT_M(req->name),
req->falloff, req->retries); req->falloff, req->retries);
req->retry_time = time(NULL) + req->falloff; req->retry_time = now_us() + req->falloff * 1000000L; // XXX scale to micro
req->falloff *= 2; req->falloff *= 2;
pthread_mutex_lock(&timer_lock); pthread_mutex_lock(&timer_lock);
@ -208,13 +208,11 @@ static void *notify_timer(void *p) {
pthread_cond_wait(&timer_cond, &timer_lock); pthread_cond_wait(&timer_cond, &timer_lock);
continue; continue;
} }
struct timeval now; int64_t now = now_us();
gettimeofday(&now, NULL); if (now < first->retry_time) {
if (now.tv_sec < first->retry_time) { ilog(LOG_DEBUG, "Sleeping until next scheduled HTTP notification retry in %" PRId64 " seconds",
ilog(LOG_DEBUG, "Sleeping until next scheduled HTTP notification retry in %lu seconds", (first->retry_time - now) / 1000000L);
(unsigned long) first->retry_time - now.tv_sec); cond_timedwait(&timer_cond, &timer_lock, first->retry_time);
struct timespec ts = {.tv_sec = first->retry_time, .tv_nsec = 0};
pthread_cond_timedwait(&timer_cond, &timer_lock, &ts);
continue; continue;
} }

Loading…
Cancel
Save