Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
varnishevent3
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
uplex-varnish
varnishevent3
Commits
49308a9e
Commit
49308a9e
authored
Feb 24, 2011
by
Poul-Henning Kamp
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Polish handling of timeval and timespec a bit.
parent
543e3dfe
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
41 additions
and
16 deletions
+41
-16
cache_acceptor.c
bin/varnishd/cache_acceptor.c
+8
-5
cache_waiter_ports.c
bin/varnishd/cache_waiter_ports.c
+1
-3
libvarnish.h
include/libvarnish.h
+2
-0
time.c
lib/libvarnish/time.c
+30
-8
No files found.
bin/varnishd/cache_acceptor.c
View file @
49308a9e
...
...
@@ -85,7 +85,7 @@ VCA_waiter_name(void)
/*--------------------------------------------------------------------
* We want to get out of any kind of touble-hit TCP connections as fast
* We want to get out of any kind of t
r
ouble-hit TCP connections as fast
* as absolutely possible, so we set them LINGER enabled with zero timeout,
* so that even if there are outstanding write data on the socket, a close(2)
* will return immediately.
...
...
@@ -203,6 +203,7 @@ vca_acct(void *arg)
socklen_t
l
;
struct
sockaddr_storage
addr_s
;
struct
sockaddr
*
addr
;
double
send_timeout
=
0
,
sess_timeout
=
0
;
int
i
;
struct
pollfd
*
pfd
;
struct
listen_sock
*
ls
;
...
...
@@ -231,9 +232,10 @@ vca_acct(void *arg)
t0
=
TIM_real
();
while
(
1
)
{
#ifdef SO_SNDTIMEO_WORKS
if
(
params
->
send_timeout
!=
tv_sndtimeo
.
tv_sec
)
{
if
(
params
->
send_timeout
!=
send_timeout
)
{
need_test
=
1
;
tv_sndtimeo
.
tv_sec
=
params
->
send_timeout
;
send_timeout
=
params
->
send_timeout
;
tv_sndtimeo
=
TIM_timeval
(
send_timeout
);
VTAILQ_FOREACH
(
ls
,
&
heritage
.
socks
,
list
)
{
if
(
ls
->
sock
<
0
)
continue
;
...
...
@@ -244,9 +246,10 @@ vca_acct(void *arg)
}
#endif
#ifdef SO_RCVTIMEO_WORKS
if
(
params
->
sess_timeout
!=
tv_rcvtimeo
.
tv_sec
)
{
if
(
params
->
sess_timeout
!=
sess_timeout
)
{
need_test
=
1
;
tv_rcvtimeo
.
tv_sec
=
params
->
sess_timeout
;
sess_timeout
=
params
->
sess_timeout
;
tv_rcvtimeo
=
TIM_timeval
(
sess_timeout
);
VTAILQ_FOREACH
(
ls
,
&
heritage
.
socks
,
list
)
{
if
(
ls
->
sock
<
0
)
continue
;
...
...
bin/varnishd/cache_waiter_ports.c
View file @
49308a9e
...
...
@@ -236,9 +236,7 @@ vca_main(void *arg)
}
else
if
(
tmo
>
max_t
)
{
timeout
=
&
max_ts
;
}
else
{
/* TIM_t2ts() ? see #630 */
ts
.
tv_sec
=
(
int
)
floor
(
tmo
);
ts
.
tv_nsec
=
1e9
*
(
tmo
-
ts
.
tv_sec
);
ts
=
TIM_timespec
(
tmo
);
timeout
=
&
ts
;
}
}
else
{
...
...
include/libvarnish.h
View file @
49308a9e
...
...
@@ -92,6 +92,8 @@ time_t TIM_parse(const char *p);
double
TIM_mono
(
void
);
double
TIM_real
(
void
);
void
TIM_sleep
(
double
t
);
struct
timespec
TIM_timespec
(
double
t
);
struct
timeval
TIM_timeval
(
double
t
);
/* from libvarnish/version.c */
void
varnish_version
(
const
char
*
);
...
...
lib/libvarnish/time.c
View file @
49308a9e
...
...
@@ -161,22 +161,44 @@ TIM_parse(const char *p)
void
TIM_sleep
(
double
t
)
{
#ifdef HAVE_NANOSLEEP
struct
timespec
ts
;
ts
.
tv_sec
=
(
time_t
)
floor
(
t
);
ts
.
tv_nsec
=
(
long
)
floor
((
t
-
ts
.
tv_sec
)
*
1e9
);
ts
=
TIM_timespec
(
t
);
#ifdef HAVE_NANOSLEEP
(
void
)
nanosleep
(
&
ts
,
NULL
);
#else
if
(
ts
.
tv_sec
>
0
)
(
void
)
sleep
(
ts
.
tv_sec
);
ts
.
tv_nsec
/=
1000
;
if
(
ts
.
tv_nsec
>
0
)
(
void
)
usleep
(
ts
.
tv_nsec
);
if
(
t
>=
1
.)
{
(
void
)
sleep
(
floor
(
t
);
t
-=
floor
(
t
);
}
/* XXX: usleep() is not mandated to be thread safe */
t
*=
1e6
;
if
(
t
>
0
)
(
void
)
usleep
(
floor
(
t
));
#endif
}
struct
timeval
TIM_timeval
(
double
t
)
{
struct
timeval
tv
;
tv
.
tv_sec
=
(
time_t
)
trunc
(
t
);
tv
.
tv_usec
=
(
int
)(
1e6
*
(
t
-
tv
.
tv_sec
));
return
(
tv
);
}
struct
timespec
TIM_timespec
(
double
t
)
{
struct
timespec
tv
;
tv
.
tv_sec
=
(
time_t
)
trunc
(
t
);
tv
.
tv_nsec
=
(
int
)(
1e9
*
(
t
-
tv
.
tv_sec
));
return
(
tv
);
}
#ifdef TEST_DRIVER
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment