r3999 - in branches/2.0/varnish-cache/bin: varnishd varnishtest

tfheen at projects.linpro.no tfheen at projects.linpro.no
Mon Mar 23 15:51:25 CET 2009


Author: tfheen
Date: 2009-03-23 15:51:24 +0100 (Mon, 23 Mar 2009)
New Revision: 3999

Modified:
   branches/2.0/varnish-cache/bin/varnishd/cache_pool.c
   branches/2.0/varnish-cache/bin/varnishtest/vtc.c
Log:
Merge r3979: Use TIM_sleep() instead of usleep()

Use TIM_sleep() instead of usleep() where duration might be longer than
the one second Open Group allows.

Fixes #475



Modified: branches/2.0/varnish-cache/bin/varnishd/cache_pool.c
===================================================================
--- branches/2.0/varnish-cache/bin/varnishd/cache_pool.c	2009-03-23 14:45:32 UTC (rev 3998)
+++ branches/2.0/varnish-cache/bin/varnishd/cache_pool.c	2009-03-23 14:51:24 UTC (rev 3999)
@@ -486,7 +486,7 @@
 	if (w != NULL) {
 		AZ(w->wrq);
 		AZ(pthread_cond_signal(&w->cond));
-		(void)usleep(params->wthread_purge_delay * 1000);
+		TIM_sleep(params->wthread_purge_delay * 1e-3);
 	}
 }
 
@@ -542,7 +542,7 @@
 		VSL_stats->n_wrk_drop = vs->n_wrk_drop;
 		VSL_stats->n_wrk_overflow = vs->n_wrk_overflow;
 
-		(void)usleep(params->wthread_purge_delay * 1000);
+		TIM_sleep(params->wthread_purge_delay * 1e-3);
 	}
 }
 
@@ -568,11 +568,11 @@
 			VSL(SLT_Debug, 0, "Create worker thread failed %d %s",
 			    errno, strerror(errno));
 			VSL_stats->n_wrk_failed++;
-			(void)usleep(params->wthread_fail_delay * 1000);
+			TIM_sleep(params->wthread_fail_delay * 1e-3);
 		} else {
 			AZ(pthread_detach(tp));
 			VSL_stats->n_wrk_create++;
-			(void)usleep(params->wthread_add_delay * 1000);
+			TIM_sleep(params->wthread_add_delay * 1e-3);
 		}
 	}
 	qp->lqueue = qp->nqueue;

Modified: branches/2.0/varnish-cache/bin/varnishtest/vtc.c
===================================================================
--- branches/2.0/varnish-cache/bin/varnishtest/vtc.c	2009-03-23 14:45:32 UTC (rev 3998)
+++ branches/2.0/varnish-cache/bin/varnishtest/vtc.c	2009-03-23 14:51:24 UTC (rev 3999)
@@ -268,11 +268,7 @@
 	AZ(av[2]);
 	f = strtod(av[1], NULL);
 	vtc_log(vl, 3, "delaying %g second(s)", f);
-	if (f > 100.) {
-		(void)sleep((int)f);
-	} else {
-		(void)usleep((int)(f * 1e6));
-	}
+	TIM_sleep(f);
 }
 
 /**********************************************************************



More information about the varnish-commit mailing list