]> git.ipfire.org Git - thirdparty/apache/httpd.git/commitdiff
Merge r442758 from trunk:
authorJim Jagielski <jim@apache.org>
Fri, 8 Dec 2006 13:07:14 +0000 (13:07 +0000)
committerJim Jagielski <jim@apache.org>
Fri, 8 Dec 2006 13:07:14 +0000 (13:07 +0000)
PR 31759 (mutated) - reported by Jo Rhett
Don't return apr_status_t error value from input filter chain.

Submitted by: niq
Reviewed by: jim

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/2.2.x@483980 13f79535-47bb-0310-9956-ffa450edef68

CHANGES
STATUS
include/util_mutex.h [new file with mode: 0644]
modules/generators/mod_cgi.c
modules/generators/mod_cgid.c
server/util_mutex.c [new file with mode: 0644]

diff --git a/CHANGES b/CHANGES
index fc9be8f1c737f35194452466272b9e68322b3d9a..d6d1c6d3e9fbcbb98d9591c526025d8b3036a126 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,6 +1,10 @@
                                                         -*- coding: utf-8 -*-
 Changes with Apache 2.2.4
 
+    * mod_cgi and mod_cgid: Don't use apr_status_t error return
+      from input filters as HTTP return value from the handler.
+      PR#31579.
+
   *) mod_cache: Eliminate a bogus error in the log when a filter returns
      AP_FILTER_ERROR. [Niklas Edmundsson <nikke acc.umu.se>]
 
diff --git a/STATUS b/STATUS
index eddafdcf6cfeeeec78321fb7c21d66c0ad816c7e..a8392cbfd109669750252d6f0a5e09d7c093013f 100644 (file)
--- a/STATUS
+++ b/STATUS
@@ -78,12 +78,6 @@ RELEASE SHOWSTOPPERS:
 PATCHES ACCEPTED TO BACKPORT FROM TRUNK:
   [ start all new proposals below, under PATCHES PROPOSED. ]
 
-    * mod_cgi and mod_cgid: Don't use apr_status_t error return
-      from input filters as HTTP return value from the handler.
-      PR#31579.
-      Trunk: http://svn.apache.org/viewvc?view=rev&revision=442758
-      +1: niq, bnicholes, wrowe
-
     * mod_mem_cache: Convert mod_mem_cache to use APR memory pool functions
       by creating a root pool for object persistence across requests. This
       also eliminates the need for custom serialization code.
diff --git a/include/util_mutex.h b/include/util_mutex.h
new file mode 100644 (file)
index 0000000..1503800
--- /dev/null
@@ -0,0 +1,60 @@
+/* Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @file  util_mutex.h
+ * @brief Apache Mutex support library
+ *
+ * @defgroup APACHE_CORE_MUTEX Mutex Library
+ * @ingroup  APACHE_CORE
+ * @{
+ */
+
+#ifndef UTIL_MUTEX_H
+#define UTIL_MUTEX_H
+
+#include "httpd.h"
+#include "apr_global_mutex.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+AP_DECLARE_DATA extern const char ap_available_mutexes_string[];
+AP_DECLARE_DATA extern const char ap_all_available_mutexes_string[];
+
+/**
+ * Get Mutex config data and parse it
+ * @param arg The mutex config string
+ * @param pool The allocation pool
+ * @param mutexmech The APR mutex locking mechanism
+ * @param mutexfile The lockfile to use as required
+ * @return APR status code
+ * @deffunc apr_status_t ap_parse_mutex(const char *arg, apr_pool_t *pool,
+                                        apr_lockmech_e *mutexmech,
+                                        const char **mutexfile)
+ */
+AP_DECLARE(apr_status_t) ap_parse_mutex(const char *arg, apr_pool_t *pool,
+                                        apr_lockmech_e *mutexmech,
+                                        const char **mutexfile);
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* UTIL_MUTEX_H */
+/** @} */
index d2f17fce630b629118aadfe53f6f44f36cef160e..133e18eb7550ff31e603f90d4fa8e53b2bc9cfd8 100644 (file)
@@ -837,7 +837,9 @@ static int cgi_handler(request_rec *r)
                             APR_BLOCK_READ, HUGE_STRING_LEN);
 
         if (rv != APR_SUCCESS) {
-            return rv;
+            ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r,
+                          "Error reading request entity data");
+            return HTTP_INTERNAL_SERVER_ERROR;
         }
 
         for (bucket = APR_BRIGADE_FIRST(bb);
index 7181e19b785a59c448710ea4f20fd1248f2a2ef1..2dc3eca12176ee90542d4e1c734608078bd72810 100644 (file)
@@ -1387,7 +1387,9 @@ static int cgid_handler(request_rec *r)
                             APR_BLOCK_READ, HUGE_STRING_LEN);
 
         if (rv != APR_SUCCESS) {
-            return rv;
+            ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r,
+                          "Error reading request entity data");
+            return HTTP_INTERNAL_SERVER_ERROR;
         }
 
         for (bucket = APR_BRIGADE_FIRST(bb);
diff --git a/server/util_mutex.c b/server/util_mutex.c
new file mode 100644 (file)
index 0000000..c8017b6
--- /dev/null
@@ -0,0 +1,167 @@
+/* Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*
+ * util_mutex.c: Useful functions for determining allowable
+ *               mutexes and mutex settings
+ */
+
+
+#include "apr.h"
+#include "apr_strings.h"
+#include "apr_lib.h"
+
+#define APR_WANT_STRFUNC
+#include "apr_want.h"
+
+#define CORE_PRIVATE
+
+#include "ap_config.h"
+#include "httpd.h"
+#include "http_main.h"
+#include "http_config.h"
+#include "util_mutex.h"
+
+AP_DECLARE_DATA const char ap_all_available_mutexes_string[] =
+    "Mutex mechanisms are: `none', `default'"
+#if APR_HAS_FLOCK_SERIALIZE
+    ", `flock:/path/to/file'"
+#endif
+#if APR_HAS_FCNTL_SERIALIZE
+    ", `fcntl:/path/to/file'"
+#endif
+#if APR_HAS_SYSVSEM_SERIALIZE && !defined(PERCHILD_MPM)
+    ", `sysvsem'"
+#endif
+#if APR_HAS_POSIXSEM_SERIALIZE
+    ", `posixsem'"
+#endif
+#if APR_HAS_PROC_PTHREAD_SERIALIZE
+    ", `pthread'"
+#endif
+#if APR_HAS_FLOCK_SERIALIZE || APR_HAS_FCNTL_SERIALIZE
+    ", `file:/path/to/file'"
+#endif
+#if (APR_HAS_SYSVSEM_SERIALIZE && !defined(PERCHILD_MPM)) || APR_HAS_POSIXSEM_SERIALIZE
+    ", `sem'"
+#endif
+    " ";
+
+AP_DECLARE_DATA const char ap_available_mutexes_string[] =
+    "Mutex mechanisms are: `default'"
+#if APR_HAS_FLOCK_SERIALIZE
+    ", `flock:/path/to/file'"
+#endif
+#if APR_HAS_FCNTL_SERIALIZE
+    ", `fcntl:/path/to/file'"
+#endif
+#if APR_HAS_SYSVSEM_SERIALIZE && !defined(PERCHILD_MPM)
+    ", `sysvsem'"
+#endif
+#if APR_HAS_POSIXSEM_SERIALIZE
+    ", `posixsem'"
+#endif
+#if APR_HAS_PROC_PTHREAD_SERIALIZE
+    ", `pthread'"
+#endif
+#if APR_HAS_FLOCK_SERIALIZE || APR_HAS_FCNTL_SERIALIZE
+    ", `file:/path/to/file'"
+#endif
+#if (APR_HAS_SYSVSEM_SERIALIZE && !defined(PERCHILD_MPM)) || APR_HAS_POSIXSEM_SERIALIZE
+    ", `sem'"
+#endif
+    " ";
+
+
+AP_DECLARE(apr_status_t) ap_parse_mutex(const char *arg, apr_pool_t *pool,
+                                        apr_lockmech_e *mutexmech,
+                                        const char **mutexfile)
+{
+    /* Split arg into meth and file */
+    char *meth = apr_pstrdup(pool, arg);
+    char *file = strchr(meth, ':');
+    if (file) {
+        *(file++) = '\0';
+        if (!*file) {
+            file = NULL;
+        }
+    }
+
+    if (!strcasecmp(meth, "none") || !strcasecmp(meth, "no")) {
+        return APR_ENOLOCK;
+    }
+
+    /* APR determines temporary filename unless overridden below,
+     * we presume file indicates an mutexfile is a file path
+     * unless the method sets mutexfile=file and NULLs file
+     */
+    *mutexfile = NULL;
+
+    /* NOTE: previously, 'yes' implied 'sem' */
+    if (!strcasecmp(meth, "default") || !strcasecmp(meth, "yes")) {
+        *mutexmech = APR_LOCK_DEFAULT;
+    }
+#if APR_HAS_FCNTL_SERIALIZE
+    else if (!strcasecmp(meth, "fcntl") || !strcasecmp(meth, "file")) {
+        *mutexmech = APR_LOCK_FCNTL;
+    }
+#endif
+#if APR_HAS_FLOCK_SERIALIZE
+    else if (!strcasecmp(meth, "flock") || !strcasecmp(meth, "file")) {
+        *mutexmech = APR_LOCK_FLOCK;
+    }
+#endif
+#if APR_HAS_POSIXSEM_SERIALIZE
+    else if (!strcasecmp(meth, "posixsem") || !strcasecmp(meth, "sem")) {
+        *mutexmech = APR_LOCK_POSIXSEM;
+        /* Posix/SysV semaphores aren't file based, use the literal name
+         * if provided and fall back on APR's default if not.  Today, APR
+         * will ignore it, but once supported it has an absurdly short limit.
+         */
+        if (file) {
+            *mutexfile = apr_pstrdup(pool, file);
+
+            file = NULL;
+        }
+    }
+#endif
+#if APR_HAS_SYSVSEM_SERIALIZE && !defined(PERCHILD_MPM)
+    else if (!strcasecmp(meth, "sysvsem") || !strcasecmp(meth, "sem")) {
+        *mutexmech = APR_LOCK_SYSVSEM;
+    }
+#endif
+#if APR_HAS_PROC_PTHREAD_SERIALIZE
+    else if (!strcasecmp(meth, "pthread")) {
+        *mutexmech = APR_LOCK_PROC_PTHREAD;
+    }
+#endif
+    else {
+        return APR_ENOTIMPL;
+    }
+
+    /* Unless the method above assumed responsibility for setting up
+     * mutexfile and NULLing out file, presume it is a file we
+     * are looking to use
+     */
+    if (file) {
+        *mutexfile = ap_server_root_relative(pool, file);
+        if (!*mutexfile) {
+            return APR_BADARG;
+        }
+    }
+
+    return APR_SUCCESS;
+}