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
a4a7384e
Commit
a4a7384e
authored
Mar 16, 2015
by
Poul-Henning Kamp
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Do not restart if we cannot get all our listen sockets, and add
a test-case to cover this case.
parent
c62cb719
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
42 additions
and
9 deletions
+42
-9
mgt.h
bin/varnishd/mgt/mgt.h
+2
-2
mgt_acceptor.c
bin/varnishd/mgt/mgt_acceptor.c
+18
-5
mgt_child.c
bin/varnishd/mgt/mgt_child.c
+1
-2
c00069.vtc
bin/varnishtest/tests/c00069.vtc
+21
-0
No files found.
bin/varnishd/mgt/mgt.h
View file @
a4a7384e
...
...
@@ -42,6 +42,8 @@ extern int exit_status;
/* mgt_acceptor.c */
void
MAC_Arg
(
const
char
*
);
int
MAC_open_sockets
(
struct
cli
*
);
void
MAC_close_sockets
(
void
);
/* mgt_child.c */
extern
pid_t
child_pid
;
...
...
@@ -49,8 +51,6 @@ void MGT_Run(void);
void
mgt_stop_child
(
void
);
void
mgt_got_fd
(
int
fd
);
void
MGT_Child_Cli_Fail
(
void
);
int
MAC_open_sockets
(
void
);
void
MAC_close_sockets
(
void
);
/* mgt_cli.c */
...
...
bin/varnishd/mgt/mgt_acceptor.c
View file @
a4a7384e
...
...
@@ -44,6 +44,7 @@
#include "common/heritage.h"
#include "vav.h"
#include "vcli_priv.h"
#include "vsa.h"
#include "vss.h"
#include "vtcp.h"
...
...
@@ -55,7 +56,7 @@
*/
int
MAC_open_sockets
(
void
)
MAC_open_sockets
(
struct
cli
*
cli
)
{
struct
listen_sock
*
ls
;
int
fail
;
...
...
@@ -73,6 +74,8 @@ MAC_open_sockets(void)
if
(
ls
==
NULL
)
return
(
0
);
MAC_close_sockets
();
VCLI_Out
(
cli
,
"Could not get socket %s: %s
\n
"
,
ls
->
name
,
strerror
(
fail
));
errno
=
fail
;
return
(
-
1
);
}
...
...
@@ -109,6 +112,8 @@ mac_callback(void *priv, const struct suckaddr *sa)
struct
mac_help
*
mh
;
struct
listen_sock
*
ls
;
int
sock
;
char
abuf
[
VTCP_ADDRBUFSIZE
],
pbuf
[
VTCP_PORTBUFSIZE
];
char
nbuf
[
VTCP_ADDRBUFSIZE
+
VTCP_PORTBUFSIZE
+
2
];
CAST_OBJ_NOTNULL
(
mh
,
priv
,
MAC_HELP_MAGIC
);
sock
=
VTCP_bind
(
sa
,
NULL
);
...
...
@@ -119,15 +124,23 @@ mac_callback(void *priv, const struct suckaddr *sa)
ALLOC_OBJ
(
ls
,
LISTEN_SOCK_MAGIC
);
AN
(
ls
);
if
(
VSA_Port
(
sa
)
==
0
)
if
(
VSA_Port
(
sa
)
==
0
)
{
/*
* If the port number is zero, we adopt whatever port number
* this VTCP_bind() found us, as if specified by argument.
*/
ls
->
addr
=
VTCP_my_suckaddr
(
sock
);
else
VTCP_myname
(
sock
,
abuf
,
sizeof
abuf
,
pbuf
,
sizeof
pbuf
);
bprintf
(
nbuf
,
"%s:%s"
,
abuf
,
pbuf
);
ls
->
name
=
strdup
(
nbuf
);
}
else
{
ls
->
addr
=
VSA_Clone
(
sa
);
ls
->
name
=
strdup
(
mh
->
name
);
}
AN
(
ls
->
addr
);
AN
(
ls
->
name
);
AZ
(
close
(
sock
));
ls
->
sock
=
-
1
;
ls
->
name
=
strdup
(
priv
);
AN
(
ls
->
name
);
VTAILQ_INSERT_TAIL
(
&
heritage
.
socks
,
ls
,
list
);
mh
->
good
++
;
return
(
0
);
...
...
bin/varnishd/mgt/mgt_child.c
View file @
a4a7384e
...
...
@@ -303,11 +303,10 @@ mgt_launch_child(struct cli *cli)
if
(
child_state
!=
CH_STOPPED
&&
child_state
!=
CH_DIED
)
return
;
if
(
MAC_open_sockets
()
!=
0
)
{
if
(
MAC_open_sockets
(
cli
)
!=
0
)
{
child_state
=
CH_STOPPED
;
if
(
cli
!=
NULL
)
{
VCLI_SetResult
(
cli
,
CLIS_CANT
);
VCLI_Out
(
cli
,
"Could not open sockets"
);
return
;
}
REPORT0
(
LOG_ERR
,
...
...
bin/varnishtest/tests/c00069.vtc
0 → 100644
View file @
a4a7384e
varnishtest "Test failure if our listen socket gets stolen"
server s1 {
rxreq
txresp
} -start
varnish v1 -arg "-a :0" -vcl+backend {} -start
client c1 {
txreq
rxresp
expect resp.status == 200
} -run
varnish v1 -stop
# Now have another varnish steal the listen socket
varnish v2 -arg "-a ${v1_addr}:${v1_port}" -vcl+backend {} -start
varnish v1 -clierr 300 "start"
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