[master] f383b5c3a vtim: New VTIM_poll_tmo() converter
Dridi Boukelmoune
dridi.boukelmoune at gmail.com
Mon Feb 5 18:19:04 UTC 2024
commit f383b5c3a469f762f0f889aee3c4b918dd1aaf37
Author: Dridi Boukelmoune <dridi.boukelmoune at gmail.com>
Date: Thu Feb 1 09:08:56 2024 +0100
vtim: New VTIM_poll_tmo() converter
It takes a vtim_dur and returns a number of milliseconds. NAN means no
timeout and negative values are considered expired deadlines and get a
chance to succeed a non-blocking poll.
diff --git a/include/vtim.h b/include/vtim.h
index d69a6130d..042feedb1 100644
--- a/include/vtim.h
+++ b/include/vtim.h
@@ -40,3 +40,4 @@ vtim_real VTIM_real(void);
void VTIM_sleep(vtim_dur t);
struct timespec VTIM_timespec(vtim_dur t);
struct timeval VTIM_timeval(vtim_dur t);
+int VTIM_poll_tmo(vtim_dur);
diff --git a/lib/libvarnish/vtim.c b/lib/libvarnish/vtim.c
index 3918e5eb2..6fdd18245 100644
--- a/lib/libvarnish/vtim.c
+++ b/lib/libvarnish/vtim.c
@@ -454,6 +454,15 @@ VTIM_timespec(vtim_dur t)
return (tv);
}
+int
+VTIM_poll_tmo(vtim_dur tmo)
+{
+
+ if (isnan(tmo))
+ return (-1);
+ return (vmax_t(int, 0, tmo * 1e3));
+}
+
#ifdef TEST_DRIVER
#pragma GCC diagnostic ignored "-Wformat-y2k"
More information about the varnish-commit
mailing list