Commit 5764fd21 authored by Helmut Grohne's avatar Helmut Grohne Committed by Helmut Grohne

Update upstream source from tag 'upstream/1.4.53'

Update to upstream version '1.4.53'
with Debian dir 6c8406aaf0c08ff1ef92408e190ce99ae6032cc0
parents 1c46edfe fb3ce416
......@@ -10,7 +10,7 @@ enable_testing()
set(CPACK_PACKAGE_VERSION_MAJOR 1)
set(CPACK_PACKAGE_VERSION_MINOR 4)
set(CPACK_PACKAGE_VERSION_PATCH 52)
set(CPACK_PACKAGE_VERSION_PATCH 53)
set(CPACK_PACKAGE_VERSION "${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}")
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_SOURCE_DIR}/COPYING")
......
......@@ -277,8 +277,8 @@ MAKEINFO = @MAKEINFO@
MANIFEST_TOOL = @MANIFEST_TOOL@
MEMCACHED_LIB = @MEMCACHED_LIB@
MKDIR_P = @MKDIR_P@
MYSQL_CFLAGS = @MYSQL_CFLAGS@
MYSQL_CONFIG = @MYSQL_CONFIG@
MYSQL_INCLUDE = @MYSQL_INCLUDE@
MYSQL_LIBS = @MYSQL_LIBS@
NM = @NM@
NMEDIT = @NMEDIT@
......
......@@ -3,6 +3,48 @@
NEWS
====
- 1.4.53 - 2019-01-27
* [mod_cml,mod_flv_streaming] fix NULL ptr deref
* [mod_simple_vhost] t/test_mod_simple_vhost
* [mod_evhost] split uri handler func for testing
* [mod_evhost] restructure for unit tests
* [mod_evhost] t/test_mod_evhost
* [mod_access] restructure for unit tests
* [mod_access] t/test_mod_access
* [tests] include first.h and NDEBUG early
* [core] use kill_signal for gw_proc_kill()
* [tests] t/test_keyvalue
* [tests] some test config cleanup
* [tests] update skip count in mod-fastcgi.t
* [multiple] reduce initial buffer sz if large POST (fixes #2922)
* [mod_fastcgi] fix NULL ptr deref from bugfix #2922 (fixes #2923)
* [tests] more test config cleanup
* [core] perf: incremental hash of pathname w/o copy
* [core] perf: reuse buffer to redirect to directory
* [core] do not free() reused buffer
* [core] use connected sock port in dir redirect
* [core] http_response_buffer_append_authority()
* [core] use con->server_name for dir redir
* [core] memeq compare rounded to 64, not next 1M
* [core] define MD5_DIGEST_LENGTH 16
* [mod_auth] permit additional auth backends to load
* [core] send Connection: close if reqbody not read (fixes #2924)
* [core] cache rev DNS for localhost for dir redir
* [doc/conf] resolve some mime type conflicts from debian buster, regenerate mime.conf
* [core] move winsock init to network_init()
* [core] move /dev/stdin graceful restart handling
* [core] network_srv_sockets_append() shared code
* [core] systemd socket activation support
* [build] autotools: try mysqlclient.pc and mariadb.pc (fixes #2925)
* [mod_expire] look up expire fallback "" explicitly
* [multiple] calloc match ptr type (clang --analyze)
* [multiple] quiet clang --analyze where trivial
* [mod_webdav] compare COPY, MOVE Destination scheme
* [core] con->uri.scheme is maintained lowercase
* [mod_openssl] ALPN and acme-tls/1 (fixes #2931)
* [core] Fix recursive include_shell invocations
* [mod_openssl] ssl.privkey directive (optional)
- 1.4.52 - 2018-11-28
* [mysql] MySQL 8 deprecates my_bool
* [core] typo in trace
......
......@@ -12,7 +12,7 @@ except NameError:
string_types = str
package = 'lighttpd'
version = '1.4.52'
version = '1.4.53'
underscorify_reg = re.compile('[^A-Z0-9]')
def underscorify(id):
......
This diff is collapsed.
......@@ -14,7 +14,7 @@ dnl - if an argument uses more than one line and is not a single
dnl function call, the argument should be on different lines than the
dnl wrapping braces
AC_PREREQ(2.60)
AC_INIT([lighttpd], [1.4.52], [contact@lighttpd.net])
AC_INIT([lighttpd], [1.4.53], [contact@lighttpd.net])
AC_CONFIG_SRCDIR([src/server.c])
AC_CONFIG_HEADER([config.h])
AC_CONFIG_MACRO_DIR([m4])
......@@ -226,32 +226,42 @@ AC_ARG_WITH([mysql],
)
AC_MSG_RESULT([$WITH_MYSQL])
MYSQL_INCLUDE=
MYSQL_CFLAGS=
MYSQL_LIBS=
if test "$WITH_MYSQL" != no; then
if test "$WITH_MYSQL" = yes; then
AC_PATH_PROG([MYSQL_CONFIG], [mysql_config])
PKG_CHECK_MODULES([MYSQL],[mariadb],[
MYSQL_CONFIG=$PKG_CONFIG
],[
PKG_CHECK_MODULES([MYSQL],[mysqlclient],[
MYSQL_CONFIG=$PKG_CONFIG
],[
AC_PATH_PROG([MYSQL_CONFIG], [mysql_config])
])
])
else
MYSQL_CONFIG=$WITH_MYSQL
fi
if test -z "$MYSQL_CONFIG"; then
AC_MSG_ERROR([mysql_config is not found])
fi
if test ! -x "$MYSQL_CONFIG"; then
AC_MSG_ERROR([mysql_config not exists or not executable, use --with-mysql=path-to-mysql_config])
fi
if test "$MYSQL_CONFIG" != "$PKG_CONFIG"; then
if test -z "$MYSQL_CONFIG"; then
AC_MSG_ERROR([mysql_config is not found])
fi
if test ! -x "$MYSQL_CONFIG"; then
AC_MSG_ERROR([mysql_config not exists or not executable, use --with-mysql=path-to-mysql_config])
fi
if "$MYSQL_CONFIG" | grep -- '--include' > /dev/null ; then
MYSQL_INCLUDE=`"$MYSQL_CONFIG" --include | sed s/\'//g`
else
MYSQL_INCLUDE=`"$MYSQL_CONFIG" --cflags | sed s/\'//g`
if "$MYSQL_CONFIG" | grep -- '--include' > /dev/null ; then
MYSQL_CFLAGS=`"$MYSQL_CONFIG" --include | sed s/\'//g`
else
MYSQL_CFLAGS=`"$MYSQL_CONFIG" --cflags | sed s/\'//g`
fi
MYSQL_LIBS=`"$MYSQL_CONFIG" --libs | sed s/\'//g`
fi
MYSQL_LIBS=`"$MYSQL_CONFIG" --libs | sed s/\'//g`
AC_MSG_CHECKING([for MySQL includes at])
AC_MSG_RESULT([$MYSQL_INCLUDE])
AC_MSG_RESULT([$MYSQL_CFLAGS])
AC_MSG_CHECKING([for MySQL libraries at])
AC_MSG_RESULT([$MYSQL_LIBS])
......@@ -261,7 +271,7 @@ fi
AM_CONDITIONAL([BUILD_WITH_MYSQL], [test "$WITH_MYSQL" != no])
AC_SUBST([MYSQL_LIBS])
AC_SUBST([MYSQL_INCLUDE])
AC_SUBST([MYSQL_CFLAGS])
dnl Checks for pgsql
AC_MSG_NOTICE([----------------------------------------])
......
......@@ -285,8 +285,8 @@ MAKEINFO = @MAKEINFO@
MANIFEST_TOOL = @MANIFEST_TOOL@
MEMCACHED_LIB = @MEMCACHED_LIB@
MKDIR_P = @MKDIR_P@
MYSQL_CFLAGS = @MYSQL_CFLAGS@
MYSQL_CONFIG = @MYSQL_CONFIG@
MYSQL_INCLUDE = @MYSQL_INCLUDE@
MYSQL_LIBS = @MYSQL_LIBS@
NM = @NM@
NMEDIT = @NMEDIT@
......
......@@ -254,8 +254,8 @@ MAKEINFO = @MAKEINFO@
MANIFEST_TOOL = @MANIFEST_TOOL@
MEMCACHED_LIB = @MEMCACHED_LIB@
MKDIR_P = @MKDIR_P@
MYSQL_CFLAGS = @MYSQL_CFLAGS@
MYSQL_CONFIG = @MYSQL_CONFIG@
MYSQL_INCLUDE = @MYSQL_INCLUDE@
MYSQL_LIBS = @MYSQL_LIBS@
NM = @NM@
NMEDIT = @NMEDIT@
......
......@@ -194,8 +194,8 @@ MAKEINFO = @MAKEINFO@
MANIFEST_TOOL = @MANIFEST_TOOL@
MEMCACHED_LIB = @MEMCACHED_LIB@
MKDIR_P = @MKDIR_P@
MYSQL_CFLAGS = @MYSQL_CFLAGS@
MYSQL_CONFIG = @MYSQL_CONFIG@
MYSQL_INCLUDE = @MYSQL_INCLUDE@
MYSQL_LIBS = @MYSQL_LIBS@
NM = @NM@
NMEDIT = @NMEDIT@
......
......@@ -52,10 +52,8 @@ mimetype.assign = (
".dcm" => "application/dicom",
".tsp" => "application/dsptype",
".es" => "application/ecmascript",
".otf" => "application/font-sfnt",
".ttf" => "application/font-sfnt",
".epub" => "application/epub+zip",
".pfr" => "application/font-tdpfr",
".woff" => "application/font-woff",
".spl" => "application/futuresplash",
".gz" => "application/gzip",
".hta" => "application/hta",
......@@ -428,6 +426,11 @@ mimetype.assign = (
".vmd" => "chemical/x-vmd",
".xtel" => "chemical/x-xtel",
".xyz" => "chemical/x-xyz",
".ttc" => "font/collection",
".otf" => "font/ttf",
".ttf" => "font/ttf",
".woff" => "font/woff",
".woff2" => "font/woff2",
".gif" => "image/gif",
".ief" => "image/ief",
".jp2" => "image/jp2",
......
......@@ -194,8 +194,8 @@ MAKEINFO = @MAKEINFO@
MANIFEST_TOOL = @MANIFEST_TOOL@
MEMCACHED_LIB = @MEMCACHED_LIB@
MKDIR_P = @MKDIR_P@
MYSQL_CFLAGS = @MYSQL_CFLAGS@
MYSQL_CONFIG = @MYSQL_CONFIG@
MYSQL_INCLUDE = @MYSQL_INCLUDE@
MYSQL_LIBS = @MYSQL_LIBS@
NM = @NM@
NMEDIT = @NMEDIT@
......
......@@ -194,8 +194,8 @@ MAKEINFO = @MAKEINFO@
MANIFEST_TOOL = @MANIFEST_TOOL@
MEMCACHED_LIB = @MEMCACHED_LIB@
MKDIR_P = @MKDIR_P@
MYSQL_CFLAGS = @MYSQL_CFLAGS@
MYSQL_CONFIG = @MYSQL_CONFIG@
MYSQL_INCLUDE = @MYSQL_INCLUDE@
MYSQL_LIBS = @MYSQL_LIBS@
NM = @NM@
NMEDIT = @NMEDIT@
......
......@@ -194,8 +194,8 @@ MAKEINFO = @MAKEINFO@
MANIFEST_TOOL = @MANIFEST_TOOL@
MEMCACHED_LIB = @MEMCACHED_LIB@
MKDIR_P = @MKDIR_P@
MYSQL_CFLAGS = @MYSQL_CFLAGS@
MYSQL_CONFIG = @MYSQL_CONFIG@
MYSQL_INCLUDE = @MYSQL_INCLUDE@
MYSQL_LIBS = @MYSQL_LIBS@
NM = @NM@
NMEDIT = @NMEDIT@
......
......@@ -45,6 +45,27 @@ my %manual_conflicts_resolve = (
'.ra' => {
'audio/x-pn-realaudio' => 'audio/x-realaudio',
},
# use font media types from iana registry
'.otf' => {
'application/font-sfnt' => 'font/ttf',
'font/sfnt' => 'font/ttf',
'font/ttf' => 'font/ttf',
},
'.ttf' => {
'application/font-sfnt' => 'font/ttf',
'font/otf' => 'font/ttf',
'font/sfnt' => 'font/ttf',
},
'.woff' => {
'application/font-woff' => 'font/woff',
},
# end of fonts
'.asn' => {
'chemical/x-ncbi-asn1-spec' => 'application/octet-stream',
},
'.ent' => {
'chemical/x-ncbi-asn1-ascii' => 'application/octet-stream',
},
);
open MIMETYPES, "/etc/mime.types" or die "Can't open /etc/mime.types: $!";
......
......@@ -194,8 +194,8 @@ MAKEINFO = @MAKEINFO@
MANIFEST_TOOL = @MANIFEST_TOOL@
MEMCACHED_LIB = @MEMCACHED_LIB@
MKDIR_P = @MKDIR_P@
MYSQL_CFLAGS = @MYSQL_CFLAGS@
MYSQL_CONFIG = @MYSQL_CONFIG@
MYSQL_INCLUDE = @MYSQL_INCLUDE@
MYSQL_LIBS = @MYSQL_LIBS@
NM = @NM@
NMEDIT = @NMEDIT@
......
project('lighttpd', 'c', version: '1.4.52', default_options : ['c_std=c11'])
project('lighttpd', 'c', version: '1.4.53', default_options : ['c_std=c11'])
subdir('src')
subdir('tests')
......
......@@ -760,6 +760,66 @@ add_executable(test_configfile
)
add_test(NAME test_configfile COMMAND test_configfile)
add_executable(test_keyvalue
t/test_keyvalue.c
burl.c
buffer.c
base64.c
array.c
data_integer.c
data_string.c
log.c
)
add_test(NAME test_keyvalue COMMAND test_keyvalue)
add_executable(test_mod_access
t/test_mod_access.c
configfile-glue.c
buffer.c
array.c
data_config.c
data_integer.c
data_string.c
http_header.c
http_kv.c
vector.c
log.c
sock_addr.c
)
add_test(NAME test_mod_access COMMAND test_mod_access)
add_executable(test_mod_evhost
t/test_mod_evhost.c
configfile-glue.c
buffer.c
array.c
data_config.c
data_integer.c
data_string.c
http_header.c
http_kv.c
vector.c
log.c
sock_addr.c
)
add_test(NAME test_mod_evhost COMMAND test_mod_evhost)
add_executable(test_mod_simple_vhost
t/test_mod_simple_vhost.c
configfile-glue.c
buffer.c
array.c
data_config.c
data_integer.c
data_string.c
http_header.c
http_kv.c
vector.c
log.c
sock_addr.c
)
add_test(NAME test_mod_simple_vhost COMMAND test_mod_simple_vhost)
add_executable(test_request
t/test_request.c
request.c
......@@ -785,6 +845,14 @@ if(HAVE_PCRE_H)
add_target_properties(mod_redirect COMPILE_FLAGS ${PCRE_CFLAGS})
target_link_libraries(test_configfile ${PCRE_LDFLAGS})
add_target_properties(test_configfile COMPILE_FLAGS ${PCRE_CFLAGS})
target_link_libraries(test_keyvalue ${PCRE_LDFLAGS})
add_target_properties(test_keyvalue COMPILE_FLAGS ${PCRE_CFLAGS})
target_link_libraries(test_mod_access ${PCRE_LDFLAGS})
add_target_properties(test_mod_access COMPILE_FLAGS ${PCRE_CFLAGS})
target_link_libraries(test_mod_evhost ${PCRE_LDFLAGS})
add_target_properties(test_mod_evhost COMPILE_FLAGS ${PCRE_CFLAGS})
target_link_libraries(test_mod_simple_vhost ${PCRE_LDFLAGS})
add_target_properties(test_mod_simple_vhost COMPILE_FLAGS ${PCRE_CFLAGS})
endif()
if(WITH_PCRE AND (WITH_MEMCACHED OR WITH_GDBM))
......@@ -982,6 +1050,14 @@ if(WITH_LIBUNWIND)
add_target_properties(test_base64 COMPILE_FLAGS ${LIBUNWIND_CFLAGS})
target_link_libraries(test_configfile ${PCRE_LDFLAGS} ${LIBUNWIND_LDFLAGS})
add_target_properties(test_configfile COMPILE_FLAGS ${PCRE_CFLAGS} ${LIBUNWIND_CFLAGS})
target_link_libraries(test_keyvalue ${PCRE_LDFLAGS} ${LIBUNWIND_LDFLAGS})
add_target_properties(test_keyvalue COMPILE_FLAGS ${PCRE_CFLAGS} ${LIBUNWIND_CFLAGS})
target_link_libraries(test_mod_access ${PCRE_LDFLAGS} ${LIBUNWIND_LDFLAGS})
add_target_properties(test_mod_access COMPILE_FLAGS ${PCRE_CFLAGS} ${LIBUNWIND_CFLAGS})
target_link_libraries(test_mod_evhost ${PCRE_LDFLAGS} ${LIBUNWIND_LDFLAGS})
add_target_properties(test_mod_evhost COMPILE_FLAGS ${PCRE_CFLAGS} ${LIBUNWIND_CFLAGS})
target_link_libraries(test_mod_simple_vhost ${PCRE_LDFLAGS} ${LIBUNWIND_LDFLAGS})
add_target_properties(test_mod_simple_vhost COMPILE_FLAGS ${PCRE_CFLAGS} ${LIBUNWIND_CFLAGS})
target_link_libraries(test_request ${LIBUNWIND_LDFLAGS})
add_target_properties(test_request COMPILE_FLAGS ${LIBUNWIND_CFLAGS})
endif()
......
......@@ -6,6 +6,10 @@ noinst_PROGRAMS=\
t/test_burl \
t/test_base64 \
t/test_configfile \
t/test_keyvalue \
t/test_mod_access \
t/test_mod_evhost \
t/test_mod_simple_vhost \
t/test_request
sbin_PROGRAMS=lighttpd lighttpd-angel
......@@ -17,6 +21,10 @@ TESTS=\
t/test_burl$(EXEEXT) \
t/test_base64$(EXEEXT) \
t/test_configfile$(EXEEXT) \
t/test_keyvalue$(EXEEXT) \
t/test_mod_access$(EXEEXT) \
t/test_mod_evhost$(EXEEXT) \
t/test_mod_simple_vhost$(EXEEXT) \
t/test_request$(EXEEXT)
lemon$(BUILD_EXEEXT): lemon.c
......@@ -178,7 +186,7 @@ lib_LTLIBRARIES += mod_mysql_vhost.la
mod_mysql_vhost_la_SOURCES = mod_mysql_vhost.c
mod_mysql_vhost_la_LDFLAGS = $(common_module_ldflags)
mod_mysql_vhost_la_LIBADD = $(MYSQL_LIBS) $(common_libadd)
mod_mysql_vhost_la_CPPFLAGS = $(MYSQL_INCLUDE)
mod_mysql_vhost_la_CPPFLAGS = $(MYSQL_CFLAGS)
endif
if BUILD_WITH_MYSQL
......@@ -186,7 +194,7 @@ lib_LTLIBRARIES += mod_vhostdb_mysql.la
mod_vhostdb_mysql_la_SOURCES = mod_vhostdb_mysql.c
mod_vhostdb_mysql_la_LDFLAGS = $(common_module_ldflags)
mod_vhostdb_mysql_la_LIBADD = $(MYSQL_LIBS) $(common_libadd)
mod_vhostdb_mysql_la_CPPFLAGS = $(MYSQL_INCLUDE)
mod_vhostdb_mysql_la_CPPFLAGS = $(MYSQL_CFLAGS)
endif
if BUILD_WITH_PGSQL
......@@ -356,7 +364,7 @@ lib_LTLIBRARIES += mod_authn_mysql.la
mod_authn_mysql_la_SOURCES = mod_authn_mysql.c
mod_authn_mysql_la_LDFLAGS = $(common_module_ldflags)
mod_authn_mysql_la_LIBADD = $(CRYPT_LIB) $(MYSQL_LIBS) $(common_libadd)
mod_authn_mysql_la_CPPFLAGS = $(MYSQL_INCLUDE)
mod_authn_mysql_la_CPPFLAGS = $(MYSQL_CFLAGS)
endif
if BUILD_WITH_SASL
......@@ -498,7 +506,7 @@ lighttpd_LDADD += $(PAM_LIB)
endif
if BUILD_WITH_MYSQL
lighttpd_SOURCES += mod_authn_mysql.c mod_mysql_vhost.c mod_vhostdb_mysql.c
lighttpd_CPPFLAGS += $(MYSQL_INCLUDE)
lighttpd_CPPFLAGS += $(MYSQL_CFLAGS)
lighttpd_LDADD += $(MYSQL_LIBS)
endif
if BUILD_WITH_PGSQL
......@@ -551,6 +559,18 @@ t_test_burl_LDADD = $(LIBUNWIND_LIBS)
t_test_configfile_SOURCES = t/test_configfile.c buffer.c array.c data_config.c data_integer.c data_string.c http_header.c http_kv.c vector.c log.c sock_addr.c
t_test_configfile_LDADD = $(PCRE_LIB) $(LIBUNWIND_LIBS)
t_test_keyvalue_SOURCES = t/test_keyvalue.c burl.c buffer.c base64.c array.c data_integer.c data_string.c log.c
t_test_keyvalue_LDADD = $(PCRE_LIB) $(LIBUNWIND_LIBS)
t_test_mod_access_SOURCES = t/test_mod_access.c configfile-glue.c buffer.c array.c data_config.c data_integer.c data_string.c http_header.c http_kv.c vector.c log.c sock_addr.c
t_test_mod_access_LDADD = $(PCRE_LIB) $(LIBUNWIND_LIBS)
t_test_mod_evhost_SOURCES = t/test_mod_evhost.c configfile-glue.c buffer.c array.c data_config.c data_integer.c data_string.c http_header.c http_kv.c vector.c log.c sock_addr.c
t_test_mod_evhost_LDADD = $(PCRE_LIB) $(LIBUNWIND_LIBS)
t_test_mod_simple_vhost_SOURCES = t/test_mod_simple_vhost.c configfile-glue.c buffer.c array.c data_config.c data_integer.c data_string.c http_header.c http_kv.c vector.c log.c sock_addr.c
t_test_mod_simple_vhost_LDADD = $(PCRE_LIB) $(LIBUNWIND_LIBS)
t_test_request_SOURCES = t/test_request.c request.c buffer.c array.c data_integer.c data_string.c http_header.c http_kv.c log.c sock_addr.c
t_test_request_LDADD = $(LIBUNWIND_LIBS)
......
This diff is collapsed.
......@@ -347,6 +347,7 @@ typedef struct {
buffer *syslog_facility;
unsigned short compat_module_load;
unsigned short systemd_socket_activation;
} server_config;
typedef struct server_socket {
......@@ -459,6 +460,8 @@ struct server {
uid_t uid;
gid_t gid;
pid_t pid;
server_socket_array srv_sockets_inherited;
};
......
......@@ -612,7 +612,6 @@ void buffer_append_string_encoded(buffer *b, const char *s, size_t s_len, buffer
d = (unsigned char*) buffer_string_prepare_append(b, d_len);
buffer_commit(b, d_len); /* fill below */
force_assert('\0' == *d);
for (ds = (unsigned char *)s, d_len = 0, ndx = 0; ndx < s_len; ds++, ndx++) {
if (map[*ds]) {
......@@ -669,7 +668,6 @@ void buffer_append_string_c_escaped(buffer *b, const char *s, size_t s_len) {
d = (unsigned char*) buffer_string_prepare_append(b, d_len);
buffer_commit(b, d_len); /* fill below */
force_assert('\0' == *d);
for (ds = (unsigned char *)s, d_len = 0, ndx = 0; ndx < s_len; ds++, ndx++) {
if ((*ds < 0x20) /* control character */
......
......@@ -325,6 +325,18 @@ void chunkqueue_append_mem(chunkqueue *cq, const char * mem, size_t len) {
}
void chunkqueue_append_mem_min(chunkqueue *cq, const char * mem, size_t len) {
chunk *c;
if (len < chunk_buf_sz && chunkqueue_append_mem_extend_chunk(cq, mem, len))
return;
c = chunk_init(len+1);
chunkqueue_append_chunk(cq, c);
cq->bytes_in += len;
buffer_copy_string_len(c->mem, mem, len);
}
void chunkqueue_append_chunkqueue(chunkqueue *cq, chunkqueue *src) {
if (src == NULL || NULL == src->first) return;
......
......@@ -60,6 +60,7 @@ void chunkqueue_set_tempdirs_default (array *tempdirs, unsigned int upload_temp_
void chunkqueue_append_file(chunkqueue *cq, buffer *fn, off_t offset, off_t len); /* copies "fn" */
void chunkqueue_append_file_fd(chunkqueue *cq, buffer *fn, int fd, off_t offset, off_t len); /* copies "fn" */
void chunkqueue_append_mem(chunkqueue *cq, const char *mem, size_t len); /* copies memory */
void chunkqueue_append_mem_min(chunkqueue *cq, const char * mem, size_t len); /* copies memory */
void chunkqueue_append_buffer(chunkqueue *cq, buffer *mem); /* may reset "mem" */
void chunkqueue_append_chunkqueue(chunkqueue *cq, chunkqueue *src);
......
......@@ -277,6 +277,7 @@ static int config_insert(server *srv) {
{ "server.syslog-facility", NULL, T_CONFIG_STRING, T_CONFIG_SCOPE_SERVER }, /* 80 */
{ "server.socket-perms", NULL, T_CONFIG_STRING, T_CONFIG_SCOPE_CONNECTION }, /* 81 */
{ "server.http-parseopts", NULL, T_CONFIG_ARRAY, T_CONFIG_SCOPE_SERVER }, /* 82 */
{ "server.systemd-socket-activation", NULL, T_CONFIG_BOOLEAN, T_CONFIG_SCOPE_SERVER }, /* 83 */
{ NULL, NULL, T_CONFIG_UNSET, T_CONFIG_SCOPE_UNSET }
};
......@@ -321,6 +322,7 @@ static int config_insert(server *srv) {
cv[80].destination = srv->srvconf.syslog_facility;
http_parseopts = array_init();
cv[82].destination = http_parseopts;
cv[83].destination = &(srv->srvconf.systemd_socket_activation);
srv->config_storage = calloc(1, srv->config_context->used * sizeof(specific_config *));
......@@ -1435,8 +1437,7 @@ int config_parse_cmd(server *srv, config_t *context, const char *cmd) {
ssize_t rd;
pid_t wpid;
int wstatus;
buffer *out = srv->tmp_buf;
buffer_clear(out);
buffer *out = buffer_init();
close(fds[1]);
fds[1] = -1;
do {
......@@ -1469,6 +1470,7 @@ int config_parse_cmd(server *srv, config_t *context, const char *cmd) {
ret = config_parse(srv, context, &t);
buffer_free(source);
}
buffer_free(out);
}
if (-1 != fds[0]) close(fds[0]);
if (-1 != fds[1]) close(fds[1]);
......
......@@ -330,7 +330,8 @@ static void gw_proc_waitpid_log(server *srv, gw_host *host, gw_proc *proc, int s
WEXITSTATUS(status), proc->connection_name);
}
} else if (WIFSIGNALED(status)) {
if (WTERMSIG(status) != SIGTERM && WTERMSIG(status) != SIGINT) {
if (WTERMSIG(status) != SIGTERM && WTERMSIG(status) != SIGINT
&& WTERMSIG(status) != host->kill_signal) {
log_error_write(srv, __FILE__, __LINE__, "sd",
"child signalled:", WTERMSIG(status));
}
......@@ -701,7 +702,7 @@ static void gw_proc_kill(server *srv, gw_host *host, gw_proc *proc) {
host->unused_procs->prev = proc;
host->unused_procs = proc;
kill(proc->pid, SIGTERM);
kill(proc->pid, host->kill_signal);
gw_proc_set_state(host, proc, PROC_STATE_KILLED);
......@@ -986,7 +987,7 @@ static int gw_establish_connection(server *srv, gw_host *host, gw_proc *proc, pi
return 0;
}
static void gw_restart_dead_procs(server *srv, gw_host *host, int debug) {
static void gw_restart_dead_procs(server *srv, gw_host *host, int debug, int trigger) {
for (gw_proc *proc = host->first; proc; proc = proc->next) {
if (debug > 2) {
log_error_write(srv, __FILE__, __LINE__, "sbdddd",
......@@ -1001,6 +1002,12 @@ static void gw_restart_dead_procs(server *srv, gw_host *host, int debug) {
gw_proc_check_enable(srv, host, proc);
break;
case PROC_STATE_KILLED:
if (trigger && ++proc->disabled_until > 4) {
int sig = (proc->disabled_until <= 8)
? host->kill_signal
: proc->disabled_until <= 16 ? SIGTERM : SIGKILL;
kill(proc->pid, sig);
}
break;
case PROC_STATE_DIED_WAIT_FOR_PID:
/*(state should not happen in workers if server.max-worker > 0)*/
......@@ -1918,7 +1925,7 @@ static handler_t gw_write_error(server *srv, gw_handler_ctx *hctx) {
/* (optimization to detect backend process exit while processing a
* large number of ready events; (this block could be removed)) */
if (0 == srv->srvconf.max_worker)
gw_restart_dead_procs(srv, hctx->host, hctx->conf.debug);
gw_restart_dead_procs(srv, hctx->host, hctx->conf.debug, 0);
/* cleanup this request and let request handler start request again */
if (hctx->reconnects++ < 5) return gw_reconnect(srv, hctx);
......@@ -2458,7 +2465,7 @@ static void gw_handle_trigger_host(server *srv, gw_host *host, int debug) {
gw_proc_waitpid(srv, host, proc);
}
gw_restart_dead_procs(srv, host, debug);
gw_restart_dead_procs(srv, host, debug, 1);
/* check if adaptive spawning enabled */
if (host->min_procs == host->max_procs) return;
......
......@@ -23,13 +23,7 @@
#include <unistd.h>
int http_response_redirect_to_directory(server *srv, connection *con) {
buffer *o;
o = buffer_init();
buffer_copy_buffer(o, con->uri.scheme);
buffer_append_string_len(o, CONST_STR_LEN("://"));
int http_response_buffer_append_authority(server *srv, connection *con, buffer *o) {
if (!buffer_string_is_empty(con->uri.authority)) {
buffer_append_string_buffer(o, con->uri.authority);
} else {
......@@ -37,35 +31,73 @@ int http_response_redirect_to_directory(server *srv, connection *con) {
sock_addr our_addr;
socklen_t our_addr_len;
our_addr.plain.sa_family = 0;
our_addr_len = sizeof(our_addr);
if (-1 == getsockname(con->fd, (struct sockaddr *)&our_addr, &our_addr_len)
|| our_addr_len > (socklen_t)sizeof(our_addr)) {
con->http_status = 500;
log_error_write(srv, __FILE__, __LINE__, "ss",
"can't get sockname", strerror(errno));
buffer_free(o);
return 0;
return -1;
}
if (our_addr.plain.sa_family == AF_INET
&& our_addr.ipv4.sin_addr.s_addr == htonl(INADDR_LOOPBACK)) {
static char lhost[32];
static size_t lhost_len = 0;
if (0 != lhost_len) {
buffer_append_string_len(o, lhost, lhost_len);
}
else {
size_t olen = buffer_string_length(o);
if (0 == sock_addr_nameinfo_append_buffer(srv, o, &our_addr)) {
lhost_len = buffer_string_length(o) - olen;
if (lhost_len < sizeof(lhost)) {
memcpy(lhost, o->ptr+olen, lhost_len+1); /*(+1 for '\0')*/
}
else {
lhost_len = 0;
}
}
else {
lhost_len = sizeof("localhost")-1;
memcpy(lhost, "localhost", lhost_len+1); /*(+1 for '\0')*/
buffer_append_string_len(o, lhost, lhost_len);
}
}
} else if (!buffer_string_is_empty(con->server_name)) {
buffer_append_string_buffer(o, con->server_name);
} else
/* Lookup name: secondly try to get hostname for bind address */
if (0 != sock_addr_nameinfo_append_buffer(srv, o, &our_addr)) {
con->http_status = 500;
buffer_free(o);
return -1;
} else {
}
{
unsigned short listen_port = sock_addr_get_port(&our_addr);
unsigned short default_port = 80;
if (buffer_is_equal_caseless_string(con->uri.scheme, CONST_STR_LEN("https"))) {
if (buffer_is_equal_string(con->uri.scheme, CONST_STR_LEN("https"))) {
default_port = 443;
}
if (default_port != srv->srvconf.port) {
if (0 == listen_port) listen_port = srv->srvconf.port;
if (default_port != listen_port) {
buffer_append_string_len(o, CONST_STR_LEN(":"));
buffer_append_int(o, srv->srvconf.port);
buffer_append_int(o, listen_port);
}
}
}
return 0;
}
int http_response_redirect_to_directory(server *srv, connection *con) {
buffer *o = srv->tmp_buf;
buffer_copy_buffer(o, con->uri.scheme);
buffer_append_string_len(o, CONST_STR_LEN("://"));
if (0 != http_response_buffer_append_authority(srv, con, o)) {
return -1;
}
buffer_append_string_encoded(o, CONST_BUF_LEN(con->uri.path), ENCODING_REL_URI);
buffer_append_string_len(o, CONST_STR_LEN("/"));
if (!buffer_string_is_empty(con->uri.query)) {
......@@ -77,9 +109,6 @@ int http_response_redirect_to_directory(server *srv, connection *con) {
con->http_status = 301;
con->file_finished = 1;