[6.0] e6c5d636f More double to vtim_* conversions
Dridi Boukelmoune
dridi.boukelmoune at gmail.com
Wed Feb 6 10:11:10 UTC 2019
commit e6c5d636f4bc9a8bd901df0b06e85dacb8b2e44f
Author: Dridi Boukelmoune <dridi.boukelmoune at gmail.com>
Date: Sat Nov 24 01:07:09 2018 +0100
More double to vtim_* conversions
This may break out of tree code not respecting include order of vdef.h
first (or via cache/cache.h). It's trivial to fix and forces consumers
to follow the tracks.
Refs #2791
diff --git a/bin/varnishd/cache/cache_panic.c b/bin/varnishd/cache/cache_panic.c
index d75e0b23f..ef6234374 100644
--- a/bin/varnishd/cache/cache_panic.c
+++ b/bin/varnishd/cache/cache_panic.c
@@ -35,9 +35,6 @@
#include <stdlib.h>
#include <signal.h>
-#include "vtim.h"
-#include "vcs.h"
-
#include "cache_varnishd.h"
#include "cache_transport.h"
@@ -47,6 +44,8 @@
#include "storage/storage.h"
#include "vcli_serve.h"
+#include "vtim.h"
+#include "vcs.h"
/*
* The panic string is constructed in memory, then copied to the
diff --git a/bin/varnishd/cache/cache_session.c b/bin/varnishd/cache/cache_session.c
index fede8e0ae..b6faa8222 100644
--- a/bin/varnishd/cache/cache_session.c
+++ b/bin/varnishd/cache/cache_session.c
@@ -255,8 +255,8 @@ enum htc_status_e
HTC_RxStuff(struct http_conn *htc, htc_complete_f *func,
double *t1, double *t2, double ti, double tn, int maxbytes)
{
- double tmo;
- double now;
+ vtim_dur tmo;
+ vtim_real now;
enum htc_status_e hs;
ssize_t z;
@@ -381,7 +381,7 @@ SES_New(struct pool *pp)
*/
static void v_matchproto_(waiter_handle_f)
-ses_handle(struct waited *wp, enum wait_event ev, double now)
+ses_handle(struct waited *wp, enum wait_event ev, vtim_real now)
{
struct sess *sp;
struct pool *pp;
@@ -518,7 +518,7 @@ SES_Close(struct sess *sp, enum sess_close reason)
*/
void
-SES_Delete(struct sess *sp, enum sess_close reason, double now)
+SES_Delete(struct sess *sp, enum sess_close reason, vtim_real now)
{
CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
diff --git a/bin/varnishd/cache/cache_varnishd.h b/bin/varnishd/cache/cache_varnishd.h
index 011ebafe7..365b821fc 100644
--- a/bin/varnishd/cache/cache_varnishd.h
+++ b/bin/varnishd/cache/cache_varnishd.h
@@ -75,8 +75,8 @@ struct http_conn {
void *priv;
/* Timeouts */
- double first_byte_timeout;
- double between_bytes_timeout;
+ vtim_dur first_byte_timeout;
+ vtim_dur between_bytes_timeout;
};
typedef enum htc_status_e htc_complete_f(struct http_conn *);
diff --git a/bin/varnishtest/vtc_haproxy.c b/bin/varnishtest/vtc_haproxy.c
index 157d0e67c..22f5eb2fe 100644
--- a/bin/varnishtest/vtc_haproxy.c
+++ b/bin/varnishtest/vtc_haproxy.c
@@ -106,7 +106,7 @@ struct haproxy_cli {
size_t rxbuf_sz;
char *rxbuf;
- double timeout;
+ vtim_dur timeout;
};
/**********************************************************************
@@ -114,7 +114,7 @@ struct haproxy_cli {
*/
static int
-haproxy_cli_tcp_connect(struct vtclog *vl, const char *addr, double tmo,
+haproxy_cli_tcp_connect(struct vtclog *vl, const char *addr, vtim_dur tmo,
const char **errp)
{
int fd;
diff --git a/bin/varnishtest/vtc_logexp.c b/bin/varnishtest/vtc_logexp.c
index 4735472e2..43e300acf 100644
--- a/bin/varnishtest/vtc_logexp.c
+++ b/bin/varnishtest/vtc_logexp.c
@@ -116,11 +116,12 @@
#include "vapi/vsm.h"
#include "vapi/vsl.h"
-#include "vtim.h"
-#include "vre.h"
#include "vtc.h"
+#include "vtim.h"
+#include "vre.h"
+
#define LE_ANY (-1)
#define LE_LAST (-2)
diff --git a/bin/varnishtest/vtc_syslog.c b/bin/varnishtest/vtc_syslog.c
index f91014c9a..666b82d3c 100644
--- a/bin/varnishtest/vtc_syslog.c
+++ b/bin/varnishtest/vtc_syslog.c
@@ -37,13 +37,13 @@
#include <string.h>
#include <unistd.h>
+#include "vtc.h"
+
#include "vsa.h"
#include "vss.h"
#include "vtcp.h"
#include "vre.h"
-#include "vtc.h"
-
struct syslog_srv {
unsigned magic;
#define SYSLOG_SRV_MAGIC 0xbf28a692
@@ -63,7 +63,7 @@ struct syslog_srv {
ssize_t rxbuf_left;
size_t rxbuf_sz;
char *rxbuf;
- double timeout;
+ vtim_dur timeout;
};
static pthread_mutex_t syslog_mtx;
diff --git a/include/vrt.h b/include/vrt.h
index 3db7c0438..53c4b773d 100644
--- a/include/vrt.h
+++ b/include/vrt.h
@@ -142,7 +142,7 @@ typedef const struct vmod_priv * VCL_BLOB;
typedef const char * VCL_BODY;
typedef unsigned VCL_BOOL;
typedef int64_t VCL_BYTES;
-typedef double VCL_DURATION;
+typedef vtim_dur VCL_DURATION;
typedef const char * VCL_ENUM;
typedef const struct gethdr_s * VCL_HEADER;
typedef struct http * VCL_HTTP;
@@ -154,7 +154,7 @@ typedef double VCL_REAL;
typedef const struct stevedore * VCL_STEVEDORE;
typedef const struct strands * VCL_STRANDS;
typedef const char * VCL_STRING;
-typedef double VCL_TIME;
+typedef vtim_real VCL_TIME;
typedef struct vcl * VCL_VCL;
typedef void VCL_VOID;
@@ -197,7 +197,7 @@ struct vrt_ctx {
struct http *http_bereq;
struct http *http_beresp;
- double now;
+ vtim_real now;
/*
* method specific argument:
@@ -260,9 +260,9 @@ extern const void * const vrt_magic_string_unset;
rigid char *port; \
rigid char *path; \
rigid char *hosthdr; \
- double connect_timeout; \
- double first_byte_timeout; \
- double between_bytes_timeout; \
+ vtim_dur connect_timeout; \
+ vtim_dur first_byte_timeout; \
+ vtim_dur between_bytes_timeout; \
unsigned max_connections; \
unsigned proxy_header;
@@ -291,8 +291,8 @@ struct vrt_backend {
};
#define VRT_BACKEND_PROBE_FIELDS(rigid) \
- double timeout; \
- double interval; \
+ vtim_dur timeout; \
+ vtim_dur interval; \
unsigned exp_status; \
unsigned window; \
unsigned threshold; \
diff --git a/include/vtcp.h b/include/vtcp.h
index 293759392..29f83cb75 100644
--- a/include/vtcp.h
+++ b/include/vtcp.h
@@ -55,13 +55,13 @@ void VTCP_name(const struct suckaddr *addr, char *abuf, unsigned alen,
char *pbuf, unsigned plen);
int VTCP_connected(int s);
int VTCP_connect(const struct suckaddr *name, int msec);
-int VTCP_open(const char *addr, const char *def_port, double timeout,
+int VTCP_open(const char *addr, const char *def_port, vtim_dur timeout,
const char **err);
void VTCP_close(int *s);
int VTCP_bind(const struct suckaddr *addr, const char **errp);
int VTCP_listen(const struct suckaddr *addr, int depth, const char **errp);
int VTCP_listen_on(const char *addr, const char *def_port, int depth,
const char **errp);
-void VTCP_set_read_timeout(int s, double seconds);
-int VTCP_read(int fd, void *ptr, size_t len, double tmo);
+void VTCP_set_read_timeout(int s, vtim_dur seconds);
+int VTCP_read(int fd, void *ptr, size_t len, vtim_dur tmo);
// #endif
diff --git a/include/vtim.h b/include/vtim.h
index 9c2e6ccfc..1968bc568 100644
--- a/include/vtim.h
+++ b/include/vtim.h
@@ -33,8 +33,8 @@ extern unsigned VTIM_postel;
#define VTIM_FORMAT_SIZE 30
void VTIM_format(double t, char *p);
double VTIM_parse(const char *p);
-double VTIM_mono(void);
-double VTIM_real(void);
-void VTIM_sleep(double t);
-struct timespec VTIM_timespec(double t);
-struct timeval VTIM_timeval(double t);
+vtim_mono VTIM_mono(void);
+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);
diff --git a/lib/libvarnish/vev.c b/lib/libvarnish/vev.c
index 0254a9cf7..771abf88b 100644
--- a/lib/libvarnish/vev.c
+++ b/lib/libvarnish/vev.c
@@ -354,7 +354,7 @@ VEV_Loop(struct vev_root *evb)
/*--------------------------------------------------------------------*/
static int
-vev_sched_timeout(struct vev_root *evb, struct vev *e, double t)
+vev_sched_timeout(struct vev_root *evb, struct vev *e, vtim_mono t)
{
int i;
diff --git a/lib/libvarnish/vtcp.c b/lib/libvarnish/vtcp.c
index 93c2fce4a..00f7f63af 100644
--- a/lib/libvarnish/vtcp.c
+++ b/lib/libvarnish/vtcp.c
@@ -52,6 +52,7 @@
#include "vsa.h"
#include "vss.h"
#include "vtcp.h"
+#include "vtim.h"
/*--------------------------------------------------------------------*/
static void
@@ -346,12 +347,10 @@ VTCP_close(int *s)
}
void
-VTCP_set_read_timeout(int s, double seconds)
+VTCP_set_read_timeout(int s, vtim_dur seconds)
{
#ifdef SO_RCVTIMEO_WORKS
- struct timeval timeout;
- timeout.tv_sec = (int)floor(seconds);
- timeout.tv_usec = (int)(1e6 * (seconds - timeout.tv_sec));
+ struct timeval timeout = VTIM_timeval(seconds);
/*
* Solaris bug (present at least in snv_151 and older): If this fails
* with EINVAL, the socket is half-closed (SS_CANTSENDMORE) and the
@@ -372,13 +371,14 @@ VTCP_set_read_timeout(int s, double seconds)
static int v_matchproto_(vss_resolved_f)
vtcp_open_callback(void *priv, const struct suckaddr *sa)
{
+ /* XXX: vtim_dur? */
double *p = priv;
return (VTCP_connect(sa, (int)floor(*p * 1e3)));
}
int
-VTCP_open(const char *addr, const char *def_port, double timeout,
+VTCP_open(const char *addr, const char *def_port, vtim_dur timeout,
const char **errp)
{
int error;
@@ -593,7 +593,7 @@ VTCP_Check(int a)
*/
int
-VTCP_read(int fd, void *ptr, size_t len, double tmo)
+VTCP_read(int fd, void *ptr, size_t len, vtim_dur tmo)
{
struct pollfd pfd[1];
int i, j;
More information about the varnish-commit
mailing list