On 07/17/2019 09:51 AM, [email protected] wrote:
> Author: jorton
> Date: Wed Jul 17 07:51:53 2019
> New Revision: 1863191
>
> URL: http://svn.apache.org/viewvc?rev=1863191&view=rev
> Log:
> mod_cgid: Continuation of r1862968, experimental fd passing support.
>
> Split out CGI bucket implementation from mod_cgi and use in both
> mod_cgi and mod_cgid, bringing stderr handling in mod_cgid up to par
> with mod_cgi.  (There is a lot of code which has been copied between
> mod_cgi{,d} so there's scope for further reduction of source
> duplication between the modules using this header)
>
> * modules/generators/cgi_common.h: Copied from mod_cgi.c, removed
>   everything but the CGI bucket implementation with only one change:
>   (struct cgi_bucket_data, cgi_bucket_create, cgi_bucket_read): Take a
>   timeout on bucket creation, store and use on reads.
>
> * modules/generators/mod_cgi.c [APR_FILES_AS_SOCKETS]: Include
>   cgi_common.h.
>   (cgi_handler): Pass configured timeout to CGI bucket.
>
> * modules/generators/mod_cgid.c: Include cgi_common.h.
>   (log_script_err): Copy from mod_cgi.c.
>   (log_script): Use log_script_err.
>   (send_req): Take fd for stderr.
>   (cgid_child_errfn): Handle fd-passing case by writing error
>   to stderr for client to pass through ap_log_rerror.
>   (cgid_handler): Create pipe for stderr, pass write-end to
>   server via send_req, use read-end to create CGI bucket.  Handle
>   stderr output in failure paths.
>
> PR: 54221
>
> Added:
>     httpd/httpd/trunk/modules/generators/cgi_common.h
>       - copied, changed from r1863117, 
> httpd/httpd/trunk/modules/generators/mod_cgi.c
> Modified:
>     httpd/httpd/trunk/docs/log-message-tags/next-number
>     httpd/httpd/trunk/modules/generators/mod_cgi.c
>     httpd/httpd/trunk/modules/generators/mod_cgid.c
>
>
> Copied: httpd/httpd/trunk/modules/generators/cgi_common.h (from r1863117, 
> httpd/httpd/trunk/modules/generators/mod_cgi.c)
> URL: 
> http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/generators/cgi_common.h?p2=httpd/httpd/trunk/modules/generators/cgi_common.h&p1=httpd/httpd/trunk/modules/generators/mod_cgi.c&r1=1863117&r2=1863191&rev=1863191&view=diff
> ==============================================================================
> --- httpd/httpd/trunk/modules/generators/mod_cgi.c (original)
> +++ httpd/httpd/trunk/modules/generators/cgi_common.h Wed Jul 17 07:51:53 2019

> @@ -598,11 +34,13 @@ static const apr_bucket_type_t bucket_ty
>  struct cgi_bucket_data {
>      apr_pollset_t *pollset;
>      request_rec *r;
> +    apr_interval_time_t timeout;
>  };
>
>  /* Create a CGI bucket using pipes from script stdout 'out'
>   * and stderr 'err', for request 'r'. */
>  static apr_bucket *cgi_bucket_create(request_rec *r,
> +                                     apr_interval_time_t timeout,
>                                       apr_file_t *out, apr_file_t *err,
>                                       apr_bucket_alloc_t *list)
>  {
> @@ -648,6 +86,7 @@ static apr_bucket *cgi_bucket_create(req
>      }
>
>      data->r = r;
> +    data->timeout = timeout;
>      b->data = data;
>      return b;
>  }
> @@ -714,10 +153,9 @@ static apr_status_t cgi_bucket_read(apr_
>      apr_interval_time_t timeout = 0;
>      apr_status_t rv;
>      int gotdata = 0;
> -    cgi_dirconf *dc = ap_get_module_config(data->r->per_dir_config, 
> &cgi_module);
>
>      if (block != APR_NONBLOCK_READ) {
> -        timeout = dc->timeout > 0 ? dc->timeout : data->r->server->timeout;
> +        timeout = data->timeout > 0 ? data->timeout : 
> data->r->server->timeout;
>      }
>
>      do {

Shouldn't that code go into something like cgi_util.c which is linked to both 
modules leaving only the structure and
prototype stuff in the header file? Or is this too much of a hassle since it 
creates some sort of CGI-API as the symbols
in cgi_util.c cannot be static but need to be exported?

Regards

Rüdiger

Reply via email to