From: Joshua Colp Date: Thu, 7 Sep 2006 16:30:44 +0000 (+0000) Subject: Let's use the same thing we use in other places to calculate our time for ast_cond_ti... X-Git-Tag: 1.2.12~7 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0367363edb8b4fa1582fec1bdbe3bab22af18d89;p=thirdparty%2Fasterisk.git Let's use the same thing we use in other places to calculate our time for ast_cond_timedwait (issue #7697 reported by bn999) git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.2@42260 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- diff --git a/cdr.c b/cdr.c index 272ce0f695..64a9e5690b 100644 --- a/cdr.c +++ b/cdr.c @@ -1044,13 +1044,14 @@ static void *do_cdr(void *data) int numevents = 0; for(;;) { - struct timeval now = ast_tvnow(); + struct timeval now; schedms = ast_sched_wait(sched); /* this shouldn't happen, but provide a 1 second default just in case */ if (schedms <= 0) schedms = 1000; - timeout.tv_sec = now.tv_sec + (schedms / 1000); - timeout.tv_nsec = (now.tv_usec * 1000) + ((schedms % 1000) * 1000); + now = ast_tvadd(ast_tvnow(), ast_samp2tv(schedms, 1000)); + timeout.tv_sec = now.tv_sec; + timeout.tv_nsec = now.tv_usec * 1000; /* prevent stuff from clobbering cdr_pending_cond, then wait on signals sent to it until the timeout expires */ ast_mutex_lock(&cdr_pending_lock); ast_cond_timedwait(&cdr_pending_cond, &cdr_pending_lock, &timeout);