httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From yla...@apache.org
Subject svn commit: r1665625 - in /httpd/httpd/trunk: modules/cache/ modules/cluster/ modules/dav/fs/ modules/dav/main/ modules/filters/ modules/generators/ modules/http/ modules/proxy/ modules/ssl/ modules/test/ server/
Date Tue, 10 Mar 2015 17:25:18 GMT
Author: ylavic
Date: Tue Mar 10 17:25:17 2015
New Revision: 1665625

URL: http://svn.apache.org/r1665625
Log:
core, modules: like r1657897 but for core and other modules than mod_proxy.

More uses of ap_map_http_request_error() and AP_FILTER_ERROR so that we never
return an HTTP error status from a handler if some filter generated a response
already.

That is, from a handler, either ap_get_brigade() (an input filter) returned
AP_FILTER_ERROR and we must forward it to ap_die(), or ap_pass_brigade() (an
output filter) failed with any status and we must return AP_FILTER_ERROR in
any case for ap_die() to determine whether a response is needed or not.

Modified:
    httpd/httpd/trunk/modules/cache/mod_file_cache.c
    httpd/httpd/trunk/modules/cluster/mod_heartmonitor.c
    httpd/httpd/trunk/modules/dav/fs/repos.c
    httpd/httpd/trunk/modules/dav/main/mod_dav.c
    httpd/httpd/trunk/modules/filters/mod_reflector.c
    httpd/httpd/trunk/modules/generators/mod_asis.c
    httpd/httpd/trunk/modules/generators/mod_cgi.c
    httpd/httpd/trunk/modules/generators/mod_cgid.c
    httpd/httpd/trunk/modules/http/http_filters.c
    httpd/httpd/trunk/modules/proxy/mod_proxy_ajp.c
    httpd/httpd/trunk/modules/ssl/ssl_engine_io.c
    httpd/httpd/trunk/modules/ssl/ssl_engine_kernel.c
    httpd/httpd/trunk/modules/test/mod_dialup.c
    httpd/httpd/trunk/server/core.c
    httpd/httpd/trunk/server/error_bucket.c
    httpd/httpd/trunk/server/util_xml.c

Modified: httpd/httpd/trunk/modules/cache/mod_file_cache.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/cache/mod_file_cache.c?rev=1665625&r1=1665624&r2=1665625&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/cache/mod_file_cache.c (original)
+++ httpd/httpd/trunk/modules/cache/mod_file_cache.c Tue Mar 10 17:25:17 2015
@@ -283,7 +283,7 @@ static int mmap_handler(request_rec *r,
     APR_BRIGADE_INSERT_TAIL(bb, b);
 
     if (ap_pass_brigade(r->output_filters, bb) != APR_SUCCESS)
-        return HTTP_INTERNAL_SERVER_ERROR;
+        return AP_FILTER_ERROR;
 #endif
     return OK;
 }
@@ -301,7 +301,7 @@ static int sendfile_handler(request_rec
     APR_BRIGADE_INSERT_TAIL(bb, b);
 
     if (ap_pass_brigade(r->output_filters, bb) != APR_SUCCESS)
-        return HTTP_INTERNAL_SERVER_ERROR;
+        return AP_FILTER_ERROR;
 #endif
     return OK;
 }

Modified: httpd/httpd/trunk/modules/cluster/mod_heartmonitor.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/cluster/mod_heartmonitor.c?rev=1665625&r1=1665624&r2=1665625&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/cluster/mod_heartmonitor.c (original)
+++ httpd/httpd/trunk/modules/cluster/mod_heartmonitor.c Tue Mar 10 17:25:17 2015
@@ -753,7 +753,7 @@ static int hm_handler(request_rec *r)
     input_brigade = apr_brigade_create(r->connection->pool, r->connection->bucket_alloc);
     status = ap_get_brigade(r->input_filters, input_brigade, AP_MODE_READBYTES, APR_BLOCK_READ,
MAX_MSG_LEN);
     if (status != APR_SUCCESS) {
-        return HTTP_INTERNAL_SERVER_ERROR;
+        return ap_map_http_request_error(status, HTTP_BAD_REQUEST);
     }
     apr_brigade_flatten(input_brigade, buf, &len);
 

Modified: httpd/httpd/trunk/modules/dav/fs/repos.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/dav/fs/repos.c?rev=1665625&r1=1665624&r2=1665625&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/dav/fs/repos.c (original)
+++ httpd/httpd/trunk/modules/dav/fs/repos.c Tue Mar 10 17:25:17 2015
@@ -1105,7 +1105,7 @@ static dav_error * dav_fs_deliver(const
     APR_BRIGADE_INSERT_TAIL(bb, bkt);
 
     if ((status = ap_pass_brigade(output, bb)) != APR_SUCCESS) {
-        return dav_new_error(pool, HTTP_FORBIDDEN, 0, status,
+        return dav_new_error(pool, AP_FILTER_ERROR, 0, status,
                              "Could not write contents to filter.");
     }
 

Modified: httpd/httpd/trunk/modules/dav/main/mod_dav.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/dav/main/mod_dav.c?rev=1665625&r1=1665624&r2=1665625&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/dav/main/mod_dav.c (original)
+++ httpd/httpd/trunk/modules/dav/main/mod_dav.c Tue Mar 10 17:25:17 2015
@@ -582,6 +582,11 @@ static int dav_handle_err(request_rec *r
     /* log the errors */
     dav_log_err(r, err, APLOG_ERR);
 
+    if (!ap_is_HTTP_VALID_RESPONSE(err->status)) {
+        /* we have responded already */
+        return AP_FILTER_ERROR;
+    }
+
     if (response == NULL) {
         dav_error *stackerr = err;
 
@@ -1006,9 +1011,7 @@ static int dav_method_put(request_rec *r
                                        "(URI: %s)", msg);
                 }
                 else {
-                    /* XXX: should this actually be HTTP_BAD_REQUEST? */
-                    http_err = ap_map_http_request_error(rc,
-                            HTTP_INTERNAL_SERVER_ERROR);
+                    http_err = ap_map_http_request_error(rc, HTTP_BAD_REQUEST);
                     msg = apr_psprintf(r->pool,
                             "An error occurred while reading"
                                     " the request body (URI: %s)", msg);

Modified: httpd/httpd/trunk/modules/filters/mod_reflector.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/filters/mod_reflector.c?rev=1665625&r1=1665624&r2=1665625&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/filters/mod_reflector.c (original)
+++ httpd/httpd/trunk/modules/filters/mod_reflector.c Tue Mar 10 17:25:17 2015
@@ -116,14 +116,8 @@ static int reflector_handler(request_rec
                                     APR_BLOCK_READ, HUGE_STRING_LEN);
 
             if (status != APR_SUCCESS) {
-                if (status == AP_FILTER_ERROR) {
-                    apr_brigade_destroy(bbin);
-                    return status;
-                }
-                else {
-                    apr_brigade_destroy(bbin);
-                    return HTTP_BAD_REQUEST;
-                }
+                apr_brigade_destroy(bbin);
+                return ap_map_http_request_error(status, HTTP_BAD_REQUEST);
             }
 
             for (bucket = APR_BRIGADE_FIRST(bbin);
@@ -160,7 +154,7 @@ static int reflector_handler(request_rec
                     ap_log_rerror(APLOG_MARK, APLOG_DEBUG, status, r, APLOGNO(01410)
                              "reflector_handler: ap_pass_brigade returned %i",
                                   status);
-                    return HTTP_INTERNAL_SERVER_ERROR;
+                    return AP_FILTER_ERROR;
                 }
 
             }

Modified: httpd/httpd/trunk/modules/generators/mod_asis.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/generators/mod_asis.c?rev=1665625&r1=1665624&r2=1665625&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/generators/mod_asis.c (original)
+++ httpd/httpd/trunk/modules/generators/mod_asis.c Tue Mar 10 17:25:17 2015
@@ -101,7 +101,7 @@ static int asis_handler(request_rec *r)
         if (rv != APR_SUCCESS) {
             ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r, APLOGNO(01236)
                           "mod_asis: ap_pass_brigade failed for file %s", r->filename);
-            return HTTP_INTERNAL_SERVER_ERROR;
+            return AP_FILTER_ERROR;
         }
     }
     else {

Modified: httpd/httpd/trunk/modules/generators/mod_cgi.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/generators/mod_cgi.c?rev=1665625&r1=1665624&r2=1665625&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/generators/mod_cgi.c (original)
+++ httpd/httpd/trunk/modules/generators/mod_cgi.c Tue Mar 10 17:25:17 2015
@@ -857,7 +857,7 @@ static int cgi_handler(request_rec *r)
             }
             ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r, APLOGNO(01225)
                           "Error reading request entity data");
-            return ap_map_http_request_error(rv, HTTP_INTERNAL_SERVER_ERROR);
+            return ap_map_http_request_error(rv, HTTP_BAD_REQUEST);
         }
 
         for (bucket = APR_BRIGADE_FIRST(bb);

Modified: httpd/httpd/trunk/modules/generators/mod_cgid.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/generators/mod_cgid.c?rev=1665625&r1=1665624&r2=1665625&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/generators/mod_cgid.c (original)
+++ httpd/httpd/trunk/modules/generators/mod_cgid.c Tue Mar 10 17:25:17 2015
@@ -1502,7 +1502,7 @@ static int cgid_handler(request_rec *r)
             }
             ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r, APLOGNO(01270)
                           "Error reading request entity data");
-            return ap_map_http_request_error(rv, HTTP_INTERNAL_SERVER_ERROR);
+            return ap_map_http_request_error(rv, HTTP_BAD_REQUEST);
         }
 
         for (bucket = APR_BRIGADE_FIRST(bb);

Modified: httpd/httpd/trunk/modules/http/http_filters.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/http/http_filters.c?rev=1665625&r1=1665624&r2=1665625&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/http/http_filters.c (original)
+++ httpd/httpd/trunk/modules/http/http_filters.c Tue Mar 10 17:25:17 2015
@@ -377,7 +377,10 @@ apr_status_t ap_http_filter(ap_filter_t
                 e = apr_bucket_flush_create(f->c->bucket_alloc);
                 APR_BRIGADE_INSERT_TAIL(bb, e);
 
-                ap_pass_brigade(f->c->output_filters, bb);
+                rv = ap_pass_brigade(f->c->output_filters, bb);
+                if (rv != APR_SUCCESS) {
+                    return AP_FILTER_ERROR;
+                }
             }
         }
     }
@@ -1597,6 +1600,13 @@ AP_DECLARE(long) ap_get_client_block(req
     /* We lose the failure code here.  This is why ap_get_client_block should
      * not be used.
      */
+    if (rv == AP_FILTER_ERROR) {
+        /* AP_FILTER_ERROR means a filter has responded already,
+         * we are DONE.
+         */
+        apr_brigade_destroy(bb);
+        return -1;
+    }
     if (rv != APR_SUCCESS) {
         apr_bucket *e;
 

Modified: httpd/httpd/trunk/modules/proxy/mod_proxy_ajp.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/proxy/mod_proxy_ajp.c?rev=1665625&r1=1665624&r2=1665625&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/proxy/mod_proxy_ajp.c (original)
+++ httpd/httpd/trunk/modules/proxy/mod_proxy_ajp.c Tue Mar 10 17:25:17 2015
@@ -395,7 +395,7 @@ static int ap_proxy_ajp_request(apr_pool
                                 rv = HTTP_REQUEST_TIME_OUT;
                             }
                             else if (status == AP_FILTER_ERROR) {
-                                data_sent = -1;
+                                rv = AP_FILTER_ERROR;
                             }
                             output_failed = 1;
                             break;
@@ -611,12 +611,7 @@ static int ap_proxy_ajp_request(apr_pool
                       "output: %i", backend_failed, output_failed);
         /* We had a failure: Close connection to backend */
         conn->close = 1;
-        if (data_sent < 0) {
-            /* Return AP_FILTER_ERROR to let ap_die() handle the error */
-            rv = AP_FILTER_ERROR;
-            data_sent = 0;
-        }
-        else if (data_sent) {
+        if (data_sent) {
             /* Return DONE to avoid error messages being added to the stream */
             rv = DONE;
         }
@@ -627,8 +622,8 @@ static int ap_proxy_ajp_request(apr_pool
         /* We had a failure: Close connection to backend */
         conn->close = 1;
         backend_failed = 1;
-        /* Return DONE to avoid error messages being added to the stream */
         if (data_sent) {
+            /* Return DONE to avoid error messages being added to the stream */
             rv = DONE;
         }
     }

Modified: httpd/httpd/trunk/modules/ssl/ssl_engine_io.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/ssl/ssl_engine_io.c?rev=1665625&r1=1665624&r2=1665625&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/ssl/ssl_engine_io.c (original)
+++ httpd/httpd/trunk/modules/ssl/ssl_engine_io.c Tue Mar 10 17:25:17 2015
@@ -1806,7 +1806,7 @@ int ssl_io_buffer_fill(request_rec *r, a
         if (rv) {
             ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r, APLOGNO(02015)
                           "could not read request body for SSL buffer");
-            return HTTP_INTERNAL_SERVER_ERROR;
+            return ap_map_http_request_error(rv, HTTP_INTERNAL_SERVER_ERROR);
         }
 
         /* Iterate through the returned brigade: setaside each bucket

Modified: httpd/httpd/trunk/modules/ssl/ssl_engine_kernel.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/ssl/ssl_engine_kernel.c?rev=1665625&r1=1665624&r2=1665625&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/ssl/ssl_engine_kernel.c (original)
+++ httpd/httpd/trunk/modules/ssl/ssl_engine_kernel.c Tue Mar 10 17:25:17 2015
@@ -133,7 +133,7 @@ int ssl_hook_ReadReq(request_rec *r)
         && (upgrade = apr_table_get(r->headers_in, "Upgrade")) != NULL
         && ap_find_token(r->pool, upgrade, "TLS/1.0")) {
         if (upgrade_connection(r)) {
-            return HTTP_INTERNAL_SERVER_ERROR;
+            return AP_FILTER_ERROR;
         }
     }
 

Modified: httpd/httpd/trunk/modules/test/mod_dialup.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/test/mod_dialup.c?rev=1665625&r1=1665624&r2=1665625&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/test/mod_dialup.c (original)
+++ httpd/httpd/trunk/modules/test/mod_dialup.c Tue Mar 10 17:25:17 2015
@@ -85,10 +85,10 @@ dialup_send_pulse(dialup_baton_t *db)
 
         apr_brigade_cleanup(db->tmpbb);
 
-        if (status != OK) {
+        if (status != APR_SUCCESS) {
             ap_log_rerror(APLOG_MARK, APLOG_ERR, status, db->r, APLOGNO(01867)
                           "dialup: pulse: ap_pass_brigade failed:");
-            return status;
+            return AP_FILTER_ERROR;
         }
     }
 
@@ -121,7 +121,7 @@ dialup_callback(void *baton)
         return;
     }
     else {
-        ap_log_rerror(APLOG_MARK, APLOG_ERR, status, db->r, APLOGNO(01868)
+        ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, db->r, APLOGNO(01868)
                       "dialup: pulse returned: %d", status);
         db->r->status = HTTP_OK;
         ap_die(status, db->r);

Modified: httpd/httpd/trunk/server/core.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/server/core.c?rev=1665625&r1=1665624&r2=1665625&view=diff
==============================================================================
--- httpd/httpd/trunk/server/core.c (original)
+++ httpd/httpd/trunk/server/core.c Tue Mar 10 17:25:17 2015
@@ -4675,7 +4675,7 @@ static int default_handler(request_rec *
             ap_log_rerror(APLOG_MARK, APLOG_DEBUG, status, r, APLOGNO(00133)
                           "default_handler: ap_pass_brigade returned %i",
                           status);
-            return HTTP_INTERNAL_SERVER_ERROR;
+            return AP_FILTER_ERROR;
         }
     }
     else {              /* unusual method (not GET or POST) */

Modified: httpd/httpd/trunk/server/error_bucket.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/server/error_bucket.c?rev=1665625&r1=1665624&r2=1665625&view=diff
==============================================================================
--- httpd/httpd/trunk/server/error_bucket.c (original)
+++ httpd/httpd/trunk/server/error_bucket.c Tue Mar 10 17:25:17 2015
@@ -61,6 +61,9 @@ AP_DECLARE(apr_bucket *) ap_bucket_error
     APR_BUCKET_INIT(b);
     b->free = apr_bucket_free;
     b->list = list;
+    if (!ap_is_HTTP_VALID_RESPONSE(error)) {
+        error = HTTP_INTERNAL_SERVER_ERROR;
+    }
     return ap_bucket_error_make(b, error, buf, p);
 }
 

Modified: httpd/httpd/trunk/server/util_xml.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/server/util_xml.c?rev=1665625&r1=1665624&r2=1665625&view=diff
==============================================================================
--- httpd/httpd/trunk/server/util_xml.c (original)
+++ httpd/httpd/trunk/server/util_xml.c Tue Mar 10 17:25:17 2015
@@ -59,6 +59,7 @@ AP_DECLARE(int) ap_xml_parse_input(reque
                                 READ_BLOCKSIZE);
 
         if (status != APR_SUCCESS) {
+            result = ap_map_http_request_error(status, HTTP_BAD_REQUEST);
             goto read_error;
         }
 



Mime
View raw message