Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
L
libvmod-all_healthy
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
libvmod-all_healthy
Commits
52e381f3
Commit
52e381f3
authored
Aug 13, 2018
by
Nils Goroll
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
better approximation of change time
parent
77b6ce82
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
33 additions
and
5 deletions
+33
-5
vmod_all_healthy.c
src/vmod_all_healthy.c
+33
-5
No files found.
src/vmod_all_healthy.c
View file @
52e381f3
...
...
@@ -34,6 +34,7 @@
#include <cache/cache.h>
#include <vcl.h>
#include <vtim.h>
#include "vcc_all_healthy_if.h"
...
...
@@ -184,23 +185,50 @@ static VCL_BACKEND vmod_director_resolve(VRT_CTX, VCL_BACKEND b)
return
(
d
->
backend
);
}
/*
* we can only approximate the change time for the unhealthy case because we do
* not have the full record: consider all backends healthy, a goes down, then b,
* a comes back up: we would need to record the time a went down initially. We
* approximate by returning the time b went down, so:
*
* - unhealthy: earliest change of unhealthy backend
* - healthy: latest change of healthy backend
*/
static
VCL_BOOL
vmod_director_healthy
(
VRT_CTX
,
VCL_BACKEND
b
,
VCL_TIME
*
t
)
{
struct
vmod_all_healthy_director
*
d
;
int
i
;
VCL_BOOL
r
=
1
;
VCL_TIME
bt
;
VCL_BOOL
br
,
r
=
1
;
VCL_TIME
bt
,
tt
[
2
]
;
CHECK_OBJ_NOTNULL
(
ctx
,
VRT_CTX_MAGIC
);
CAST_OBJ_NOTNULL
(
d
,
b
->
priv
,
VMOD_ALL_HEALTHY_DIRECTOR_MAGIC
);
if
(
t
)
{
tt
[
0
]
=
VTIM_real
();
tt
[
1
]
=
0
.
0
;
}
for
(
i
=
0
;
i
<
d
->
nconsider
;
i
++
)
{
CHECK_OBJ_NOTNULL
(
d
->
consider
[
i
],
DIRECTOR_MAGIC
);
r
&=
VRT_Healthy
(
ctx
,
d
->
consider
[
i
],
&
bt
);
if
(
t
&&
bt
>
*
t
)
*
t
=
bt
;
br
=
!!
VRT_Healthy
(
ctx
,
d
->
consider
[
i
],
&
bt
);
r
&=
br
;
if
(
t
)
{
if
(
r
&&
br
)
{
if
(
bt
>
tt
[
1
])
tt
[
1
]
=
bt
;
}
else
if
(
!
br
)
{
if
(
bt
<
tt
[
0
])
tt
[
0
]
=
bt
;
}
}
}
assert
(
r
==
0
||
r
==
1
);
if
(
t
)
*
t
=
tt
[
r
];
return
(
r
);
}
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