Mailing List Archive

r3260 - in trunk/varnish-cache: bin/varnishd include lib/libvarnish
Author: tfheen
Date: 2008-10-07 11:46:21 +0200 (Tue, 07 Oct 2008)
New Revision: 3260

Modified:
trunk/varnish-cache/bin/varnishd/cache_backend_poll.c
trunk/varnish-cache/include/libvarnish.h
trunk/varnish-cache/lib/libvarnish/time.c
Log:
Move dsleep to libvarnish/time.c and rename it to TIM_sleep


Modified: trunk/varnish-cache/bin/varnishd/cache_backend_poll.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_backend_poll.c 2008-10-05 22:45:41 UTC (rev 3259)
+++ trunk/varnish-cache/bin/varnishd/cache_backend_poll.c 2008-10-07 09:46:21 UTC (rev 3260)
@@ -91,15 +91,6 @@
"Connection: close\r\n"
"\r\n";

-static void
-dsleep(double t)
-{
- if (t > 100.0)
- (void)sleep((int)round(t));
- else
- (void)usleep((int)round(t * 1e6));
-}
-
/*--------------------------------------------------------------------
* Poke one backend, once, but possibly at both IPv4 and IPv6 addresses.
*
@@ -330,7 +321,7 @@
vt->last, vt->avg, vt->resp_buf);

if (!vt->stop)
- dsleep(vt->probe.interval);
+ TIM_sleep(vt->probe.interval);
}
return (NULL);
}

Modified: trunk/varnish-cache/include/libvarnish.h
===================================================================
--- trunk/varnish-cache/include/libvarnish.h 2008-10-05 22:45:41 UTC (rev 3259)
+++ trunk/varnish-cache/include/libvarnish.h 2008-10-07 09:46:21 UTC (rev 3260)
@@ -70,6 +70,7 @@
time_t TIM_parse(const char *p);
double TIM_mono(void);
double TIM_real(void);
+void TIM_sleep(double t);

/* from libvarnish/version.c */
void varnish_version(const char *);

Modified: trunk/varnish-cache/lib/libvarnish/time.c
===================================================================
--- trunk/varnish-cache/lib/libvarnish/time.c 2008-10-05 22:45:41 UTC (rev 3259)
+++ trunk/varnish-cache/lib/libvarnish/time.c 2008-10-07 09:46:21 UTC (rev 3260)
@@ -53,6 +53,8 @@
#include <stdio.h>
#include <string.h>
#include <time.h>
+#include <unistd.h>
+#include <math.h>

#include "config.h"
#include "libvarnish.h"
@@ -148,6 +150,16 @@
return (0);
}

+void
+TIM_sleep(double t)
+{
+ if (t > 100.0)
+ (void)sleep((int)round(t));
+ else
+ (void)usleep((int)round(t * 1e6));
+}
+
+
#ifdef TEST_DRIVER

#include <stdlib.h>