Skip to content

Commit

Permalink
SNAP-0910052141 patch commited
Browse files Browse the repository at this point in the history
  • Loading branch information
Mathieu CARBONNEAUX committed Apr 10, 2016
1 parent 9bd2a9a commit 43cbbc8
Show file tree
Hide file tree
Showing 10 changed files with 297 additions and 79 deletions.
69 changes: 68 additions & 1 deletion CHANGES
@@ -1,4 +1,71 @@
2.4.3
2.4.7

*) *nix: On graceful restart, send SIGTERM, then wait 2sec before
removing any unix domain sockets. Based on a patch by Bernd Wurst.

*) Fix uid_t/gid_t compiler warnings. [Artur Zaprzala <arturz ownmail.net>]

*) A few more EINTR fixes. [Artur Zaprzala <arturz ownmail.net>]

*) Don't let the Content-Length header propagate on errors or across
redirects. [Artur Zaprzala <arturz ownmail.net>]

*) Fix pass-header handling (prefix with HTTP_). Based on a patch by
[Christian Seiler <chris_se gmx.net>]

*) Add an EOS bucket to the output filter chain. Based on a patch by
[Philipp Dunkel <p.dunkel i5invest.com>]

*) Handle EINTR and EAGAIN in places AIX stress testing revealed
issues. Based on a patch by [Rainer Jung <rainer.jung kippdata.de>]

*) Fix process spawning on WIN under Apache 2.2.9 (an incompatible
change was introduced in APR 1.3). Patch by
[Tom Donovan <Tom tomdonovan.net>]

*) Allow duplicate Status, Location and ContentType headers
(consistent with mod_cgi). Based on a patch by
[Christian Seiler <chris_se gmx.net>]

*) Fix a spurious idle timeout error that occurred under unique
application timing and response size conditions. Based on a
report and patch by [Joe Strout <joe strout.net>]

2.4.6

*) Fix a bug I introduced in 2.4.4 that broke dynamic application
restarts. Reported by [Yar <yarodin gmail.com>]

2.4.4

*) Allow FastCgiServer and FastCgiExternal server directives
to be used within VirtualHosts (again). Add docs to explain
potential accessibility from other VirtualHosts.
[Rob Saccoccio <robs fastcgi.com>]

*) Check for a null filename in the request to prevent an NPE that
was occurring when a WebSphere Apache module was also in use.
[Fabian Pehla <fabian pehla.de>}

*) [AP2] Call ap_set_content_type() rather than setting the content_type
directly so that the AddOutputFilterByType directive can work correctly.
[Thomas 'Freaky' Hurst <tom.hurst clara.net>]

*) Don't use initializers for timeval structs because on 64bit
MVS there is a padding field in between tv_sec and tv_usec.
[Eric Covener <covener gmail.com>]

*) [AP2] Add support for nph (non parsed header) scripts.
[Peter Zijlstra <peterz nedstat.com>]

*) Abort the request if the client connection ends prematurely.
[Peter Zijlstra <peterz nedstat.com>]

*) Introduce the apr_* backward compatibility macros removed
in Apache 2.2. ["Daniel Smertnig" <daniel.smertnig gmail.com>]

*) Fix a problem (remove install-modules) in Makefile.AP2 under
Apache 2.2. ["Daniel Smertnig" <daniel.smertnig gmail.com>]

*) Don't count an application exit towards the number of
failures when doing restart backoff handling if the exit
Expand Down
2 changes: 1 addition & 1 deletion Win32/mod_fastcgi-AP2.dsp

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

50 changes: 37 additions & 13 deletions docs/mod_fastcgi.html
@@ -1,6 +1,6 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<HTML>
<!-- $Id: mod_fastcgi.html,v 1.35 2004/01/07 02:02:31 robs Exp $ -->
<!-- $Id: mod_fastcgi.html,v 1.39 2008/09/22 00:28:56 robs Exp $ -->
<HEAD>
<TITLE>
Apache module mod_fastcgi
Expand Down Expand Up @@ -159,9 +159,7 @@ <H2>
<P>
FastCGI application output is buffered by default. This is not the case for CGI scripts (under Apache 1.3).
To override the default behavior, use the <CODE>-flush</CODE> option (not available for dynamic
applications). Non-parsed header (nph-) scripts will be rejected by mod_fastcgi simply as warning the
behavior is different (create a symbolic link to the script without the &quot;nph-&quot; prefix if this
poses a problem).
applications).
</P>
<P>
Redirects are handled similarly to CGI. Location headers with values that begin with &quot;/&quot; are
Expand Down Expand Up @@ -280,7 +278,7 @@ <H2>
"Help"><STRONG>Context:</STRONG></A>
</TD>
<TD>
server config
server config, virtual host
</TD>
</TR>
</TABLE>
Expand All @@ -296,6 +294,12 @@ <H2>
HREF="http://httpd.apache.org/docs/mod/core.html#loglevel"><CODE>LogLevel</CODE></A>).
</P>
<P>
<B>Note:</B> Using <CODE>FastCgiServer</CODE> within a
<A HREF="http://httpd.apache.org/docs/mod/core.html#virtualhost">VirtualHost</A>
does not necessarily limited access to that host. If <EM>filename</EM> is
accessible via other virtual hosts, they too can leverage the same definition.
</P>
<P>
<EM>Option</EM> can be one of (case insensitive):
</P>
<DL>
Expand Down Expand Up @@ -376,13 +380,20 @@ <H2>
interval is increased to 600 seconds. The server will get 3 tries to run for at least this
number of seconds.
</DD>
<DT>
<CODE><STRONG>-nph</STRONG></CODE>
</DT>
<DD>
Instructs mod_fastcgi not to parse the headers. See the Apache documentation for more information
about <em>nph</em> (non parse header) scripts.
</DD>
<DT>
<CODE><STRONG>-pass-header <EM>header</EM></STRONG> (none)</CODE>
</DT>
<DD>
The name of an HTTP Request Header to be passed in the <EM>request</EM> environment. This option makes
The name of a Request Header to be passed in the <EM>request</EM> environment. This option makes
available the contents of headers which are normally not available (e.g. Authorization) to a CGI
environment.
environment. The passed header names are prefixed with "HTTP_" IAW the CGI specification.
</DD>
<DT>
<CODE><STRONG>-port <EM>n</EM></STRONG> (none)</CODE>
Expand Down Expand Up @@ -612,9 +623,9 @@ <H2>
<CODE><STRONG>-pass-header <EM>header</EM></STRONG> (none)</CODE>
</DT>
<DD>
The name of an HTTP Request Header to be passed in the <EM>request</EM> environment. This option makes
The name of a Request Header to be passed in the <EM>request</EM> environment. This option makes
available the contents of headers which are normally not available (e.g. Authorization) to a CGI
environment.
environment. The passed header names are prefixed with "HTTP_" IAW the CGI specification.
</DD>
<DT>
<CODE><STRONG>-priority <EM>n</EM></STRONG> (0)</CODE>
Expand Down Expand Up @@ -703,7 +714,7 @@ <H2>
"Help"><STRONG>Context:</STRONG></A>
</TD>
<TD>
server config
server config, virtual host
</TD>
</TR>
</TABLE>
Expand All @@ -712,7 +723,7 @@ <H2>
application. If <EM>filename</EM> does not begin with a slash (/) then it is assumed to be relative to the
<A HREF="http://httpd.apache.org/docs/mod/core.html#serverroot">ServerRoot</A>. The <EM>filename</EM> does
not have to exist in the local filesystem. URIs that Apache resolves to this <EM>filename</EM> will be
handled by this external FastCGI application..
handled by this external FastCGI application.
</P>
<P>
External FastCGI applications are not started by the process manager, they are presumed to be started and
Expand All @@ -721,6 +732,12 @@ <H2>
be <EM>self-starting</EM>, see the devkit).
</P>
<P>
<B>Note:</B> Using <CODE>FastCgiServer</CODE> within a
<A HREF="http://httpd.apache.org/docs/mod/core.html#virtualhost">VirtualHost</A>
does not necessarily limited access to that host. If <EM>filename</EM> is
accessible via other virtual hosts, they too can leverage the same definition.
</P>
<P>
<EM>Option</EM> can be one of (case insensitive):
</P>
<DL>
Expand Down Expand Up @@ -775,13 +792,20 @@ <H2>
The hostname or IP address and TCP port number (1-65535) the application uses for communication with
the web server. The <CODE>-socket</CODE> and <CODE>-host</CODE> options are mutually exclusive.
</DD>
<DT>
<CODE><STRONG>-nph</STRONG></CODE>
</DT>
<DD>
Instructs mod_fastcgi not to parse the headers. See the Apache documentation for more information
about <em>nph</em> (non parse header) scripts.
</DD>
<DT>
<CODE><STRONG>-pass-header <EM>header</EM></STRONG> (none)</CODE>
</DT>
<DD>
The name of an HTTP Request Header to be passed in the <EM>request</EM> environment. This option makes
The name of a Request Header to be passed in the <EM>request</EM> environment. This option makes
available the contents of headers which are normally not available (e.g. Authorization) to a CGI
environment.
environment. The passed header names are prefixed with "HTTP_" IAW the CGI specification.
</DD>
<DT>
<CODE><STRONG>-socket <EM>filename</EM></STRONG> (none)</CODE>
Expand Down
4 changes: 3 additions & 1 deletion fcgi.h
@@ -1,5 +1,5 @@
/*
* $Id: fcgi.h,v 1.45 2004/01/07 01:56:00 robs Exp $
* $Id: fcgi.h,v 1.48 2008/09/22 10:36:06 robs Exp $
*/

#ifndef FCGI_H
Expand Down Expand Up @@ -81,6 +81,7 @@ typedef apr_status_t apcb_t;
#define ap_copy_table apr_table_copy
#define ap_cpystrn apr_cpystrn
#define ap_destroy_pool apr_pool_destroy
#define ap_isalnum apr_isalnum
#define ap_isspace apr_isspace
#define ap_make_array apr_array_make
#define ap_make_table apr_table_make
Expand All @@ -100,6 +101,7 @@ typedef apr_status_t apcb_t;
#define ap_table_set apr_table_set
#define ap_table_setn apr_table_setn
#define ap_table_unset apr_table_unset
#define ap_toupper apr_toupper

#endif /* defined(ap_copy_table) */

Expand Down
22 changes: 12 additions & 10 deletions fcgi_config.c
@@ -1,5 +1,5 @@
/*
* $Id: fcgi_config.c,v 1.50 2004/01/07 01:56:00 robs Exp $
* $Id: fcgi_config.c,v 1.54 2009/09/28 12:33:14 robs Exp $
*/

#define CORE_PRIVATE
Expand Down Expand Up @@ -604,7 +604,7 @@ const char *fcgi_config_new_static_server(cmd_parms *cmd, void *dummy, const cha
HANDLE mutex;
#endif

err = ap_check_cmd_context(cmd, GLOBAL_ONLY);
err = ap_check_cmd_context(cmd, NOT_IN_LIMIT|NOT_IN_DIR_LOC_FILE);
if (err)
{
return err;
Expand Down Expand Up @@ -694,7 +694,7 @@ const char *fcgi_config_new_static_server(cmd_parms *cmd, void *dummy, const cha
return invalid_value(tp, name, fs_path, option, err);
}
else if (strcasecmp(option, "-min-server-life") == 0) {
if ((err = get_int(tp, &arg, &s->minServerLife, 0)))
if ((err = get_u_int(tp, &arg, &s->minServerLife, 0)))
return invalid_value(tp, name, NULL, option, err);
}
else if (strcasecmp(option, "-priority") == 0) {
Expand Down Expand Up @@ -766,12 +766,12 @@ const char *fcgi_config_new_static_server(cmd_parms *cmd, void *dummy, const cha
{
if (s->group == NULL)
{
s->group = ap_psprintf(tp, "#%ld", fcgi_util_get_server_gid(cmd->server));
s->group = ap_psprintf(tp, "#%ld", (long) fcgi_util_get_server_gid(cmd->server));
}

if (s->user == NULL)
{
s->user = ap_psprintf(p, "#%ld", fcgi_util_get_server_uid(cmd->server));
s->user = ap_psprintf(p, "#%ld", (long) fcgi_util_get_server_uid(cmd->server));
}

s->uid = ap_uname2id(s->user);
Expand Down Expand Up @@ -854,9 +854,8 @@ const char *fcgi_config_new_external_server(cmd_parms *cmd, void *dummy, const c
char *fs_path = ap_getword_conf(p, &arg);
const char *option, *err;

err = ap_check_cmd_context(cmd, GLOBAL_ONLY);
if (err)
{
err = ap_check_cmd_context(cmd, NOT_IN_LIMIT|NOT_IN_DIR_LOC_FILE);
if (err) {
return err;
}

Expand Down Expand Up @@ -919,6 +918,9 @@ const char *fcgi_config_new_external_server(cmd_parms *cmd, void *dummy, const c
if ((err = get_u_int(tp, &arg, &s->idle_timeout, 1)))
return invalid_value(tp, name, fs_path, option, err);
}
else if (strcasecmp(option, "-nph") == 0) {
s->nph = 1;
}
else if (strcasecmp(option, "-pass-header") == 0) {
if ((err = get_pass_header(p, &arg, &s->pass_headers)))
return invalid_value(tp, name, fs_path, option, err);
Expand Down Expand Up @@ -957,12 +959,12 @@ const char *fcgi_config_new_external_server(cmd_parms *cmd, void *dummy, const c
{
if (s->group == NULL)
{
s->group = ap_psprintf(tp, "#%ld", fcgi_util_get_server_gid(cmd->server));
s->group = ap_psprintf(tp, "#%ld", (long) fcgi_util_get_server_gid(cmd->server));
}

if (s->user == NULL)
{
s->user = ap_psprintf(p, "#%ld", fcgi_util_get_server_uid(cmd->server));
s->user = ap_psprintf(p, "#%ld", (long) fcgi_util_get_server_uid(cmd->server));
}

s->uid = ap_uname2id(s->user);
Expand Down
47 changes: 39 additions & 8 deletions fcgi_pm.c
@@ -1,5 +1,5 @@
/*
* $Id: fcgi_pm.c,v 1.93 2004/04/15 02:01:26 robs Exp $
* $Id: fcgi_pm.c,v 1.96 2009/09/29 00:34:10 robs Exp $
*/


Expand Down Expand Up @@ -32,6 +32,7 @@ static time_t now = 0;
#ifdef WIN32
#ifdef APACHE2
#include "mod_cgi.h"
#include "apr_version.h"
#endif
#pragma warning ( disable : 4100 4102 )
static BOOL bTimeToDie = FALSE; /* process termination flag */
Expand Down Expand Up @@ -129,7 +130,34 @@ static void shutdown_all()
? dynamicMaxClassProcs
: s->numProcesses;

/* Send TERM to all processes */
for (i = 0; i < numChildren; i++, proc++)
{
if (proc->state == FCGI_RUNNING_STATE)
{
fcgi_kill(proc, SIGTERM);
}
}

s = s->next;
}

#ifndef WIN32

s = fcgi_servers;
while (s)
{
if (s->socket_path != NULL && s->directive != APP_CLASS_EXTERNAL)
{
struct timeval tv;

/* sleep two seconds to let the children terminate themselves */
tv.tv_sec = 2;
tv.tv_usec = 0;
ap_select(0, NULL, NULL, NULL, &tv);

while (s)
{
if (s->socket_path != NULL && s->directive != APP_CLASS_EXTERNAL)
{
/* Remove the socket file */
Expand All @@ -140,20 +168,18 @@ static void shutdown_all()
(s->directive == APP_CLASS_DYNAMIC) ? " (dynamic)" : "", s->fs_path);
}
}
#endif

/* Send TERM to all processes */
for (i = 0; i < numChildren; i++, proc++)
{
if (proc->state == FCGI_RUNNING_STATE)
{
fcgi_kill(proc, SIGTERM);
s = s->next;
}

break;
}

s = s->next;
}

#endif

#if defined(WIN32) && (WIN32_SHUTDOWN_GRACEFUL_WAIT > 0)

/*
Expand Down Expand Up @@ -559,6 +585,11 @@ static pid_t spawn_fs_process(fcgi_server *fs, ServerProcess *process)
if (apr_os_file_put(&file, &listen_handle, 0, tp))
goto CLEANUP;

#if (APR_MAJOR_VERSION >= 1) && (APR_MINOR_VERSION >= 3)
if (apr_procattr_io_set(procattr, APR_FULL_BLOCK, APR_NO_FILE, APR_NO_FILE))
goto CLEANUP;
#endif

/* procattr is opaque so we have to use this - unfortuantely it dups */
if (apr_procattr_child_in_set(procattr, file, NULL))
goto CLEANUP;
Expand Down

0 comments on commit 43cbbc8

Please sign in to comment.