You are viewing a plain text version of this content. The canonical link for it is here.
Posted to mod_python-commits@quetz.apache.org by gr...@apache.org on 2006/05/08 13:08:36 UTC

svn commit: r405016 - in /httpd/mod_python/trunk: lib/python/mod_python/__init__.py src/include/mpversion.h src/mod_python.c

Author: grahamd
Date: Mon May  8 04:08:32 2006
New Revision: 405016

URL: http://svn.apache.org/viewcvs?rev=405016&view=rev
Log:
Eliminated crash when dynamically registered filters used in conjunction with
PythonInterpPerDirective. (MODPYTHON-103)

Modified:
    httpd/mod_python/trunk/lib/python/mod_python/__init__.py
    httpd/mod_python/trunk/src/include/mpversion.h
    httpd/mod_python/trunk/src/mod_python.c

Modified: httpd/mod_python/trunk/lib/python/mod_python/__init__.py
URL: http://svn.apache.org/viewcvs/httpd/mod_python/trunk/lib/python/mod_python/__init__.py?rev=405016&r1=405015&r2=405016&view=diff
==============================================================================
--- httpd/mod_python/trunk/lib/python/mod_python/__init__.py (original)
+++ httpd/mod_python/trunk/lib/python/mod_python/__init__.py Mon May  8 04:08:32 2006
@@ -20,5 +20,5 @@
 __all__ = ["apache", "cgihandler", "psp",
            "publisher", "util", "python22"]
 
-version = "3.3.0-dev-20060507"
+version = "3.3.0-dev-20060508"
 

Modified: httpd/mod_python/trunk/src/include/mpversion.h
URL: http://svn.apache.org/viewcvs/httpd/mod_python/trunk/src/include/mpversion.h?rev=405016&r1=405015&r2=405016&view=diff
==============================================================================
--- httpd/mod_python/trunk/src/include/mpversion.h (original)
+++ httpd/mod_python/trunk/src/include/mpversion.h Mon May  8 04:08:32 2006
@@ -1,5 +1,5 @@
 #define MPV_MAJOR 3
 #define MPV_MINOR 3
 #define MPV_PATCH 0
-#define MPV_BUILD 20060507
-#define MPV_STRING "3.3.0-dev-20060507"
+#define MPV_BUILD 20060508
+#define MPV_STRING "3.3.0-dev-20060508"

Modified: httpd/mod_python/trunk/src/mod_python.c
URL: http://svn.apache.org/viewcvs/httpd/mod_python/trunk/src/mod_python.c?rev=405016&r1=405015&r2=405016&view=diff
==============================================================================
--- httpd/mod_python/trunk/src/mod_python.c (original)
+++ httpd/mod_python/trunk/src/mod_python.c Mon May  8 04:08:32 2006
@@ -1211,10 +1211,11 @@
  *      is specified, then its a connection handler.
  */
 
-static const char *select_interp_name(request_rec *req, conn_rec *con, py_config *conf, 
-                                      hl_entry *hle, const char *fname, int is_input)
+static const char *select_interp_name(request_rec *req, conn_rec *con,
+                                      py_config *conf, hl_entry *hle,
+                                      py_handler *fh)
 {
-    const char *s;
+    const char *s = NULL;
 
     if ((s = apr_table_get(conf->directives, "PythonInterpreter"))) {
         /* forced by configuration */
@@ -1261,18 +1262,10 @@
             
             py_handler *fh;
 
-            if (fname) {
-                if (is_input) {
-                    fh = (py_handler *)apr_hash_get(conf->in_filters, fname,
-                                                           APR_HASH_KEY_STRING);
-                }
-                else {
-                    fh = (py_handler *)apr_hash_get(conf->out_filters, fname,
-                                                           APR_HASH_KEY_STRING);
-                }
+            if (fh) {
                 s = fh->directory;
             }
-            else {
+            else if (hle) {
                 s = hle->directory;
             }
 
@@ -1359,9 +1352,9 @@
 
     /* determine interpreter to use */
     if (hle)
-        interp_name = select_interp_name(req, NULL, conf, hle, NULL, 0);
+        interp_name = select_interp_name(req, NULL, conf, hle, NULL);
     else
-        interp_name = select_interp_name(req, NULL, conf, dynhle, NULL, 0);
+        interp_name = select_interp_name(req, NULL, conf, dynhle, NULL);
 
     /* get/create interpreter */
     idata = get_interpreter(interp_name, req->server);
@@ -1558,7 +1551,7 @@
     }
     
     /* determine interpreter to use */
-    interp_name = select_interp_name(NULL, con, conf, hle, NULL, 0);
+    interp_name = select_interp_name(NULL, con, conf, hle, NULL);
 
     /* get/create interpreter */
     idata = get_interpreter(interp_name, con->base_server);
@@ -1658,24 +1651,8 @@
     conf = (py_config *) ap_get_module_config(req->per_dir_config, 
                                                   &python_module);
 
-    /* determine interpreter to use */
-    interp_name = select_interp_name(req, NULL, conf, NULL, f->frec->name, is_input);
-
-    /* get/create interpreter */
-    idata = get_interpreter(interp_name, req->server);
-   
-    if (!idata) {
-        ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, 0, req,
-                      "python_filter: Can't get/create interpreter.");
-        return HTTP_INTERNAL_SERVER_ERROR;
-    }
-
-    /* create/acquire request object */
-    request_obj = python_get_request_object(req, 0);
-
     req_config = (py_req_config *) ap_get_module_config(req->request_config,
                                                         &python_module);
-
     /* the name of python function to call */
     if (ctx->name) {
         if (is_input)
@@ -1692,10 +1669,24 @@
     if (!fh) {
         ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, 0, req,
                       "python_filter: Could not find registered filter.");
-        release_interpreter();
         return HTTP_INTERNAL_SERVER_ERROR;
     }
 
+    /* determine interpreter to use */
+    interp_name = select_interp_name(req, NULL, conf, NULL, fh);
+
+    /* get/create interpreter */
+    idata = get_interpreter(interp_name, req->server);
+   
+    if (!idata) {
+        ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, 0, req,
+                      "python_filter: Can't get/create interpreter.");
+        return HTTP_INTERNAL_SERVER_ERROR;
+    }
+
+    /* create/acquire request object */
+    request_obj = python_get_request_object(req, 0);
+
     /* create filter */
     filter = (filterobject *)MpFilter_FromFilter(f, bb, is_input, mode, readbytes,
                                                  fh->handler, fh->directory);
@@ -1856,7 +1847,7 @@
                                               &python_module);
 
     /* determine interpreter to use */
-    interp_name = select_interp_name(req, NULL, conf, NULL, f->frec->name, 0);
+    interp_name = select_interp_name(req, NULL, conf, NULL, NULL);
 
     /* get/create interpreter */
     idata = get_interpreter(interp_name, req->server);
@@ -1997,7 +1988,7 @@
                                               &python_module);
 
     /* determine interpreter to use */
-    interp_name = select_interp_name(req, NULL, conf, NULL, f->frec->name, 0);
+    interp_name = select_interp_name(req, NULL, conf, NULL, NULL);
 
     /* get/create interpreter */
     idata = get_interpreter(interp_name, req->server);