]> err.no Git - varnish/commitdiff
Move dsleep to libvarnish/time.c and rename it to TIM_sleep
authorTollef Fog Heen <tfheen@err.no>
Mon, 6 Oct 2008 12:33:48 +0000 (14:33 +0200)
committerTollef Fog Heen <tfheen@err.no>
Tue, 7 Oct 2008 09:43:48 +0000 (11:43 +0200)
varnish-cache/bin/varnishd/cache_backend_poll.c
varnish-cache/include/libvarnish.h
varnish-cache/lib/libvarnish/time.c

index 53c82f24f7129ef86168657ad941928ec0c67a65..68ac92a8599cd13b0fa915ebac6dc52918284995 100644 (file)
@@ -91,15 +91,6 @@ static char default_request[] =
     "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 @@ vbp_wrk_poll_backend(void *priv)
                    vt->last, vt->avg, vt->resp_buf);
                        
                if (!vt->stop)
-                       dsleep(vt->probe.interval);
+                       TIM_sleep(vt->probe.interval);
        }
        return (NULL);
 }
index e250c33bf55540f0b0e587860653f48cd8a9a0d8..a7ddb4707dc6cd4f5a3573c047d4e521fae2851f 100644 (file)
@@ -70,6 +70,7 @@ void TIM_format(double t, char *p);
 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 *);
index 0f2cce7dd39ebf9abf1c8c9b64039fb9fabf74af..370256494048a5f8f5bdc9e12cc5ff67abea29de 100644 (file)
@@ -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 @@ TIM_parse(const char *p)
        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>