httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From n.@apache.org
Subject cvs commit: httpd-2.0/server core.c request.c
Date Thu, 29 May 2003 23:04:32 GMT
nd          2003/05/29 16:04:32

  Modified:    include  http_core.h
               modules/http http_request.c
               server   core.c request.c
  Log:
  Rework of the recursion stopper - collapse recursion counters into one function
  
  Reviewed by: Justin Erenkrantz
  
  Revision  Changes    Path
  1.76      +3 -11     httpd-2.0/include/http_core.h
  
  Index: http_core.h
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/include/http_core.h,v
  retrieving revision 1.75
  retrieving revision 1.76
  diff -u -r1.75 -r1.76
  --- http_core.h	19 May 2003 01:19:55 -0000	1.75
  +++ http_core.h	29 May 2003 23:04:31 -0000	1.76
  @@ -264,20 +264,12 @@
   AP_DECLARE(void) ap_custom_response(request_rec *r, int status, const char *string);
   
   /**
  - * Check if the current request is beyond the configured max. number of redirects
  + * Check if the current request is beyond the configured max. number of redirects or subrequests
    * @param r The current request
    * @return true (is exceeded) or false
  - * @deffunc int ap_is_redirect_limit_exceeded(const request_rec *r)
  + * @deffunc int ap_is_recursion_limit_exceeded(const request_rec *r)
    */
  -AP_DECLARE(int) ap_is_redirect_limit_exceeded(const request_rec *r);
  -
  -/**
  - * Check if the current request is beyond the configured subreq nesting level
  - * @param r The current request
  - * @return true (is exceeded) or false
  - * @deffunc int ap_is_subreq_limit_exceeded(const request_rec *r)
  - */
  -AP_DECLARE(int) ap_is_subreq_limit_exceeded(const request_rec *r);
  +AP_DECLARE(int) ap_is_recursion_limit_exceeded(const request_rec *r);
   
   /**
    * Check for a definition from the server command line
  
  
  
  1.158     +1 -1      httpd-2.0/modules/http/http_request.c
  
  Index: http_request.c
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/modules/http/http_request.c,v
  retrieving revision 1.157
  retrieving revision 1.158
  diff -u -r1.157 -r1.158
  --- http_request.c	29 May 2003 15:07:12 -0000	1.157
  +++ http_request.c	29 May 2003 23:04:31 -0000	1.158
  @@ -334,7 +334,7 @@
       int access_status;
       request_rec *new;
   
  -    if (ap_is_redirect_limit_exceeded(r)) {
  +    if (ap_is_recursion_limit_exceeded(r)) {
           ap_die(HTTP_INTERNAL_SERVER_ERROR, r);
           return NULL;
       }
  
  
  
  1.237     +58 -70    httpd-2.0/server/core.c
  
  Index: core.c
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/server/core.c,v
  retrieving revision 1.236
  retrieving revision 1.237
  diff -u -r1.236 -r1.237
  --- core.c	19 May 2003 01:19:55 -0000	1.236
  +++ core.c	29 May 2003 23:04:32 -0000	1.237
  @@ -2661,102 +2661,90 @@
       return NULL;
   }
   
  -static void log_backtrace(const request_rec *top, const request_rec *r)
  +static void log_backtrace(const request_rec *r)
   {
  -    while (top) {
  -        ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r,
  -                      "redirected from r->uri = %s",
  -                      top->uri ? top->uri : "(unexpectedly NULL)");
  +    const request_rec *top = r;
  +
  +    ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r,
  +                  "r->uri = %s", r->uri ? r->uri : "(unexpectedly NULL)");
  +
  +    while (top && (top->prev || top->main)) {
  +        if (top->prev) {
  +            top = top->prev;
  +            ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r,
  +                          "redirected from r->uri = %s",
  +                          top->uri ? top->uri : "(unexpectedly NULL)");
  +        }
   
           if (!top->prev && top->main) {
               top = top->main;
  -
               ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r,
                             "subrequested from r->uri = %s",
                             top->uri ? top->uri : "(unexpectedly NULL)");
           }
  -        else {
  -            top = top->prev;
  -        }
       }
   }
   
   /*
    * check whether redirect limit is reached
    */
  -AP_DECLARE(int) ap_is_redirect_limit_exceeded(const request_rec *r)
  +AP_DECLARE(int) ap_is_recursion_limit_exceeded(const request_rec *r)
   {
       core_server_config *conf = ap_get_module_config(r->server->module_config,
                                                       &core_module);
       const request_rec *top = r;
  -    int redirects = 0;
  -    int limit = conf->redirect_limit
  -                ? conf->redirect_limit
  -                : AP_DEFAULT_MAX_INTERNAL_REDIRECTS;
  -
  -    while (top->prev) {
  -        if (++redirects >= limit) {
  -            /* uuh, too much. */
  -            ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r,
  -                          "Request exceeded the limit of %d internal redirects "
  -                          "due to probable configuration error. Use "
  -                          "'LimitInternalRecursion' to increase the limit if "
  -                          "necessary. Use 'LogLevel debug' to get a "
  -                          "backtrace.", limit);
  +    int redirects = 0, subreqs = 0;
  +    int rlimit = conf->redirect_limit
  +                 ? conf->redirect_limit
  +                 : AP_DEFAULT_MAX_INTERNAL_REDIRECTS;
  +    int slimit = conf->subreq_limit
  +                 ? conf->subreq_limit
  +                 : AP_DEFAULT_MAX_SUBREQ_DEPTH;
  +
  +
  +    while (top->prev || top->main) {
  +        if (top->prev) {
  +            if (++redirects >= rlimit) {
  +                /* uuh, too much. */
  +                ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r,
  +                              "Request exceeded the limit of %d internal "
  +                              "redirects due to probable configuration error. "
  +                              "Use 'LimitInternalRecursion' to increase the "
  +                              "limit if necessary. Use 'LogLevel debug' to get "
  +                              "a backtrace.", rlimit);
  +
  +                /* post backtrace */
  +                log_backtrace(r);
  +
  +                /* return failure */
  +                return 1;
  +            }
   
  -            /* post backtrace */
  -            log_backtrace(r->prev, r);
  -
  -            /* return failure */
  -            return 1;
  -        }
  -
  -        if (!top->prev && top->main) {
  -            top = top->main;
  -        }
  -        else {
               top = top->prev;
           }
  -    }
  -
  -    /* number of redirects is ok */
  -    return 0;
  -}
  -
  -/*
  - * check whether subrequest depth limit is reached
  - */
  -AP_DECLARE(int) ap_is_subreq_limit_exceeded(const request_rec *r)
  -{
  -    core_server_config *conf = ap_get_module_config(r->server->module_config,
  -                                                    &core_module);
  -    const request_rec *top = r;
  -    int subreqs = 0;
  -    int limit = conf->subreq_limit
  -                ? conf->subreq_limit
  -                : AP_DEFAULT_MAX_SUBREQ_DEPTH;
  -
  -    while (top->main) {
  -        if (++subreqs >= limit) {
  -            /* uuh, too much. */
  -            ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r,
  -                          "Request exceeded the limit of %d subrequest "
  -                          "nesting levels due to probable confguration error. "
  -                          "Use 'LimitInternalRecursion' to increase the limit "
  -                          "if necessary. Use 'LogLevel debug' to get a "
  -                          "backtrace.", limit);
   
  -            /* post backtrace */
  -            log_backtrace(r->main, r);
  +        if (!top->prev && top->main) {
  +            if (++subreqs >= slimit) {
  +                /* uuh, too much. */
  +                ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r,
  +                              "Request exceeded the limit of %d subrequest "
  +                              "nesting levels due to probable confguration "
  +                              "error. Use 'LimitInternalRecursion' to increase "
  +                              "the limit if necessary. Use 'LogLevel debug' to "
  +                              "get a backtrace.", slimit);
  +
  +                /* post backtrace */
  +                log_backtrace(r);
  +
  +                /* return failure */
  +                return 1;
  +            }
   
  -            /* return failure */
  -            return 1;
  +            top = top->main;
           }
  -
  -        top = top->main;
       }
   
  -    /* number of subrequests is ok */
  +    /* recursion state: ok */
       return 0;
   }
   
  
  
  
  1.127     +3 -3      httpd-2.0/server/request.c
  
  Index: request.c
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/server/request.c,v
  retrieving revision 1.126
  retrieving revision 1.127
  diff -u -r1.126 -r1.127
  --- request.c	19 May 2003 01:19:55 -0000	1.126
  +++ request.c	29 May 2003 23:04:32 -0000	1.127
  @@ -1634,7 +1634,7 @@
   
       /* We cannot return NULL without violating the API. So just turn this
        * subrequest into a 500 to indicate the failure. */
  -    if (ap_is_subreq_limit_exceeded(r)) {
  +    if (ap_is_recursion_limit_exceeded(r)) {
           rnew->status = HTTP_INTERNAL_SERVER_ERROR;
           return rnew;
       }
  @@ -1774,7 +1774,7 @@
   
       /* We cannot return NULL without violating the API. So just turn this
        * subrequest into a 500. */
  -    if (ap_is_subreq_limit_exceeded(r)) {
  +    if (ap_is_recursion_limit_exceeded(r)) {
           rnew->status = HTTP_INTERNAL_SERVER_ERROR;
           return rnew;
       }
  @@ -1868,7 +1868,7 @@
   
       /* We cannot return NULL without violating the API. So just turn this
        * subrequest into a 500. */
  -    if (ap_is_subreq_limit_exceeded(r)) {
  +    if (ap_is_recursion_limit_exceeded(r)) {
           rnew->status = HTTP_INTERNAL_SERVER_ERROR;
           return rnew;
       }
  
  
  

Mime
View raw message