Index: httpd-2.4.16/modules/aaa/mod_authnz_fcgi.c =================================================================== --- httpd-2.4.16.orig/modules/aaa/mod_authnz_fcgi.c +++ httpd-2.4.16/modules/aaa/mod_authnz_fcgi.c @@ -41,6 +41,7 @@ typedef struct { apr_sockaddr_t *backend_addrs; int is_authn; int is_authz; + int timeout; /* socket io timeout */ } fcgi_provider_conf; typedef struct { @@ -63,8 +64,6 @@ typedef struct { static apr_hash_t *fcgi_authn_providers, *fcgi_authz_providers; -#define FCGI_IO_TIMEOUT apr_time_from_sec(30) - #ifndef NON200_RESPONSE_BUF_LEN #define NON200_RESPONSE_BUF_LEN 8192 #endif @@ -72,6 +71,9 @@ static apr_hash_t *fcgi_authn_providers, /* fcgi://{hostname|IPv4|IPv6}:port[/] */ #define FCGI_BACKEND_REGEX_STR "m%^fcgi://(.*):(\\d{1,5})/?$%" +/* Optional socket IO timeout parameter regex. For e.g.: timeout=60 */ +#define FCGI_IO_TIMEOUT_REGEX_STR "m%^timeout=(\\d{1,3})$%" + /* * utility function to connect to a peer; generally useful, but * wait for AF_UNIX support in this mod before thinking about how @@ -718,7 +720,7 @@ static void req_rsp(request_rec *r, cons setupenv(r, password, apache_role); rv = connect_to_peer(&s, r, conf->backend_addrs, - conf->backend, FCGI_IO_TIMEOUT); + conf->backend, apr_time_from_sec(conf->timeout)); if (rv == APR_SUCCESS) { apr_uint16_t request_id = 1; @@ -1163,7 +1165,7 @@ static const char *fcgi_define_provider( char *const argv[]) { const char *dname = "AuthnzFcgiDefineProvider"; - ap_rxplus_t *fcgi_backend_regex; + ap_rxplus_t *fcgi_backend_regex, *fcgi_io_timeout_regex; apr_status_t rv; char *host; const char *err, *stype; @@ -1177,6 +1179,13 @@ static const char *fcgi_define_provider( dname, FCGI_BACKEND_REGEX_STR); } + fcgi_io_timeout_regex = ap_rxplus_compile(cmd->pool, FCGI_IO_TIMEOUT_REGEX_STR); + if (!fcgi_io_timeout_regex) { + return apr_psprintf(cmd->pool, + "%s: failed to compile regexec '%s'", + dname, FCGI_IO_TIMEOUT_REGEX_STR); + } + err = ap_check_cmd_context(cmd, GLOBAL_ONLY); if (err) return err; @@ -1257,6 +1266,16 @@ static const char *fcgi_define_provider( NULL); } + if ((ca <= argc) && !strncmp(argv[ca], "timeout=", strlen("timeout="))) { + rc = ap_rxplus_exec(cmd->pool, fcgi_io_timeout_regex, argv[ca], NULL); + if (!rc || ap_rxplus_nmatch(fcgi_io_timeout_regex) != 2) { + return apr_pstrcat(cmd->pool, dname, ": timeout parameter '", + argv[ca], "' has invalid form", NULL); + } + ca++; + conf->timeout = atoi(ap_rxplus_pmatch(cmd->pool, fcgi_io_timeout_regex, 1)); + } + if (ca != argc) { return apr_pstrcat(cmd->pool, dname,