Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
varnish-cache
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
varnishcache
varnish-cache
Commits
0d746632
Commit
0d746632
authored
Feb 02, 2021
by
Poul-Henning Kamp
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
VTCP_open should try all possible addresses before giving up.
Fixes #3509
parent
9570000b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
31 additions
and
5 deletions
+31
-5
vtcp.c
lib/libvarnish/vtcp.c
+31
-5
No files found.
lib/libvarnish/vtcp.c
View file @
0d746632
...
...
@@ -51,6 +51,7 @@
#include <stdlib.h>
#include "vdef.h"
#include "miniobj.h"
#include "vas.h"
#include "vsa.h"
#include "vss.h"
...
...
@@ -371,25 +372,50 @@ VTCP_set_read_timeout(int s, vtim_dur seconds)
/*--------------------------------------------------------------------
*/
struct
vto_priv
{
unsigned
magic
;
#define VTO_PRIV_MAGIC 0xca70b0e7
int
latest_errno
;
int
fd
;
double
timeout
;
};
static
int
v_matchproto_
(
vss_resolved_f
)
vtcp_open_callback
(
void
*
priv
,
const
struct
suckaddr
*
sa
)
{
/* XXX: vtim_dur? */
double
*
p
=
priv
;
struct
vto_priv
*
vto
;
int
fd
;
return
(
VTCP_connect
(
sa
,
(
int
)
floor
(
*
p
*
1e3
)));
CAST_OBJ_NOTNULL
(
vto
,
priv
,
VTO_PRIV_MAGIC
);
errno
=
0
;
fd
=
VTCP_connect
(
sa
,
(
int
)
floor
(
vto
->
timeout
*
1e3
));
if
(
fd
>
0
)
{
vto
->
fd
=
fd
;
vto
->
latest_errno
=
0
;
return
(
1
);
}
vto
->
latest_errno
=
errno
;
return
(
0
);
}
int
VTCP_open
(
const
char
*
addr
,
const
char
*
def_port
,
vtim_dur
timeout
,
const
char
**
errp
)
{
struct
vto_priv
vto
[
1
];
AN
(
errp
);
assert
(
timeout
>=
0
);
INIT_OBJ
(
vto
,
VTO_PRIV_MAGIC
);
vto
->
fd
=
-
1
;
vto
->
timeout
=
timeout
;
return
(
VSS_resolver
(
addr
,
def_port
,
vtcp_open_callback
,
&
timeout
,
errp
));
if
(
VSS_resolver
(
addr
,
def_port
,
vtcp_open_callback
,
vto
,
errp
)
<
0
)
return
(
-
1
);
if
(
vto
->
fd
<
0
)
*
errp
=
strerror
(
vto
->
latest_errno
);
return
(
vto
->
fd
);
}
/*--------------------------------------------------------------------
...
...
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