[mod_fastcgi,mod_scgi] check for spawning on same unix socket (#319)

error out if duplicated unix socket path and different bin-path is
used by lighttpd to start the backend.  This is an error.
Updates commits 97556d99 and b67ff2aa

x-ref:
  "Should warn if two FastCGI servers point to same socket file"
  https://redmine.lighttpd.net/issues/319
This commit is contained in:
Glenn Strauss 2016-07-10 17:22:10 -04:00
parent b67ff2aaca
commit c1af146a6e
2 changed files with 16 additions and 2 deletions

View File

@ -1194,7 +1194,8 @@ static fcgi_extension_host * unixsocket_is_dup(plugin_data *p, size_t used, buff
for (n = 0; n < ex->used; ++n) {
fcgi_extension_host *host = ex->hosts[n];
if (!buffer_string_is_empty(host->unixsocket)
&& buffer_is_equal(host->unixsocket, unixsocket))
&& buffer_is_equal(host->unixsocket, unixsocket)
&& !buffer_string_is_empty(host->bin_path))
return host;
}
}
@ -1392,6 +1393,12 @@ SETDEFAULTS_FUNC(mod_fastcgi_set_defaults) {
if (!buffer_string_is_empty(host->bin_path)) {
fcgi_extension_host *duplicate = unixsocket_is_dup(p, i+1, host->unixsocket);
if (NULL != duplicate) {
if (!buffer_is_equal(host->bin_path, duplicate->bin_path)) {
log_error_write(srv, __FILE__, __LINE__, "sb",
"duplicate unixsocket path:",
host->unixsocket);
goto error;
}
fastcgi_host_free(host);
host = duplicate;
++host->refcount;

View File

@ -961,7 +961,8 @@ static scgi_extension_host * unixsocket_is_dup(plugin_data *p, size_t used, buff
for (n = 0; n < ex->used; ++n) {
scgi_extension_host *host = ex->hosts[n];
if (!buffer_string_is_empty(host->unixsocket)
&& buffer_is_equal(host->unixsocket, unixsocket))
&& buffer_is_equal(host->unixsocket, unixsocket)
&& !buffer_string_is_empty(host->bin_path))
return host;
}
}
@ -1144,6 +1145,12 @@ SETDEFAULTS_FUNC(mod_scgi_set_defaults) {
if (!buffer_string_is_empty(df->bin_path)) {
scgi_extension_host *duplicate = unixsocket_is_dup(p, i+1, df->unixsocket);
if (NULL != duplicate) {
if (!buffer_is_equal(df->bin_path, duplicate->bin_path)) {
log_error_write(srv, __FILE__, __LINE__, "sb",
"duplicate unixsocket path:",
df->unixsocket);
goto error;
}
scgi_host_free(df);
df = duplicate;
++df->refcount;