summaryrefslogtreecommitdiff
path: root/src/network.c
diff options
context:
space:
mode:
authorGlenn Strauss <gstrauss@gluelogic.com>2016-03-26 13:39:54 +0000
committerStefan B├╝hler <stbuehler@web.de>2016-03-26 13:39:54 +0000
commit292309f88b3ebf083ea69202943add6e907d3321 (patch)
tree9b6680d212663a76a3a970072515af50fd606480 /src/network.c
parent9ae781368532bd831aeac1a769c8ca27a60e9736 (diff)
downloadlighttpd1.4-292309f88b3ebf083ea69202943add6e907d3321.tar.gz
lighttpd1.4-292309f88b3ebf083ea69202943add6e907d3321.zip
[core] lighttpd -tt performs preflight startup checks (fixes #411)
lighttpd -t loads config file and performs syntax check lighttpd -tt (new) performs preflight startup checks, including loading and initializing modules, but skipping any potentially destructive actions which might affect an already running server (separate instance). These currently include: - skipping pidfile modification - skipping bind() to network sockets - skipping open of error and access logs From: Glenn Strauss <gstrauss@gluelogic.com> git-svn-id: svn://svn.lighttpd.net/lighttpd/branches/lighttpd-1.4.x@3130 152afb58-edef-0310-8abb-c4023f1b3aa9
Diffstat (limited to 'src/network.c')
-rw-r--r--src/network.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/network.c b/src/network.c
index 0f66ebca..09339095 100644
--- a/src/network.c
+++ b/src/network.c
@@ -170,11 +170,11 @@ static int network_server_init(server *srv, buffer *host_token, specific_config
buffer *b;
int is_unix_domain_socket = 0;
int fd;
+ int err;
#ifdef __WIN32
WORD wVersionRequested;
WSADATA wsaData;
- int err;
wVersionRequested = MAKEWORD( 2, 2 );
@@ -185,6 +185,7 @@ static int network_server_init(server *srv, buffer *host_token, specific_config
return -1;
}
#endif
+ err = -1;
srv_socket = calloc(1, sizeof(*srv_socket));
force_assert(NULL != srv_socket);
@@ -380,6 +381,8 @@ static int network_server_init(server *srv, buffer *host_token, specific_config
#endif
}
+ if (srv->srvconf.preflight_check) break;
+
/* check if the socket exists and try to connect to it. */
if (-1 != (fd = connect(srv_socket->fd, (struct sockaddr *) &(srv_socket->addr), addr_len))) {
close(fd);
@@ -412,6 +415,11 @@ static int network_server_init(server *srv, buffer *host_token, specific_config
goto error_free_socket;
}
+ if (srv->srvconf.preflight_check) {
+ err = 0;
+ goto error_free_socket;
+ }
+
if (0 != bind(srv_socket->fd, (struct sockaddr *) &(srv_socket->addr), addr_len)) {
switch(srv_socket->addr.plain.sa_family) {
case AF_UNIX:
@@ -501,7 +509,7 @@ error_free_socket:
buffer_free(b);
- return -1;
+ return err; /* -1 if error; 0 if srv->srvconf.preflight_check successful */
}
int network_close(server *srv) {