Commit 2bd3cea0 authored by Dridi Boukelmoune's avatar Dridi Boukelmoune

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
parent f3e9c54c
......@@ -34,9 +34,6 @@
#include <stdlib.h>
#include <signal.h>
#include "vtim.h"
#include "vcs.h"
#include "cache_varnishd.h"
#include "cache_transport.h"
......@@ -46,6 +43,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
......
......@@ -254,8 +254,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;
......@@ -380,7 +380,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;
......@@ -517,7 +517,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);
......
......@@ -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 *);
......
......@@ -105,7 +105,7 @@ struct haproxy_cli {
size_t rxbuf_sz;
char *rxbuf;
double timeout;
vtim_dur timeout;
};
/**********************************************************************
......@@ -113,7 +113,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;
......
......@@ -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)
......
......@@ -36,13 +36,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
......@@ -62,7 +62,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;
......
......@@ -158,7 +158,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;
......@@ -170,7 +170,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;
......@@ -213,7 +213,7 @@ struct vrt_ctx {
VCL_HTTP http_bereq;
VCL_HTTP http_beresp;
double now;
vtim_real now;
/*
* method specific argument:
......@@ -276,9 +276,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;
......@@ -307,8 +307,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; \
......
......@@ -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
......@@ -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);
......@@ -353,7 +353,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;
......
......@@ -51,6 +51,7 @@
#include "vsa.h"
#include "vss.h"
#include "vtcp.h"
#include "vtim.h"
/*--------------------------------------------------------------------*/
static void
......@@ -345,12 +346,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
......@@ -371,13 +370,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;
......@@ -592,7 +592,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;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment