perl-modperl-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From steve...@apache.org
Subject svn commit: r1602105 [3/7] - in /perl/modperl/trunk: ./ ModPerl-Registry/lib/ModPerl/ ModPerl-Registry/t/ ModPerl-Registry/t/cgi-bin/ ModPerl-Registry/t/conf/ build/ lib/ lib/APR/ lib/Apache2/ lib/Apache2/PerlSections/ lib/Bundle/ lib/ModPerl/ src/modu...
Date Thu, 12 Jun 2014 09:29:19 GMT
Modified: perl/modperl/trunk/src/modules/perl/modperl_common_log.c
URL: http://svn.apache.org/viewvc/perl/modperl/trunk/src/modules/perl/modperl_common_log.c?rev=1602105&r1=1602104&r2=1602105&view=diff
==============================================================================
--- perl/modperl/trunk/src/modules/perl/modperl_common_log.c (original)
+++ perl/modperl/trunk/src/modules/perl/modperl_common_log.c Thu Jun 12 09:29:09 2014
@@ -16,6 +16,7 @@
 
 #include "modperl_common_includes.h"
 #include "modperl_common_log.h"
+#include "modperl_debug.h"
 
 #undef getenv /* from XSUB.h */
 
@@ -48,7 +49,36 @@ void modperl_trace(const char *func, con
         return;
     }
 
-    if (func) {
+    /* for more information on formatting codes see
+       http://apr.apache.org/docs/apr/1.4/group__apr__lib.html#gad2cd3594aeaafd45931d1034965f48c1
+     */
+
+    /* PERL_GET_CONTEXT yields nonsense until the first interpreter is
+     * created. Hence the modperl_is_running() question. */
+    if (modperl_threaded_mpm()) {
+        if (modperl_threads_started()) {
+            apr_os_thread_t tid = apr_os_thread_current();
+            apr_file_printf(logfile, "[pid=%lu, tid=%pt, perl=%pp] ",
+                            (unsigned long)getpid(), &tid,
+                            modperl_is_running() ? PERL_GET_CONTEXT : NULL);
+        }
+        else {
+            apr_file_printf(logfile, "[pid=%lu, perl=%pp] ",
+                            (unsigned long)getpid(),
+                            modperl_is_running() ? PERL_GET_CONTEXT : NULL);
+        }
+    }
+    else {
+#ifdef USE_ITHREADS
+        apr_file_printf(logfile, "[pid=%lu, perl=%pp] ",
+                        (unsigned long)getpid(),
+                        modperl_is_running() ? PERL_GET_CONTEXT : NULL);
+#else
+        apr_file_printf(logfile, "[pid=%lu] ", (unsigned long)getpid());
+#endif
+    }
+
+    if (func && *func) {
         apr_file_printf(logfile, "%s: ", func);
     }
 
@@ -90,3 +120,10 @@ void modperl_trace_level_set(apr_file_t 
 
     MP_TRACE_any_do(MP_TRACE_dump_flags());
 }
+
+/*
+ * Local Variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ */

Modified: perl/modperl/trunk/src/modules/perl/modperl_common_log.h
URL: http://svn.apache.org/viewvc/perl/modperl/trunk/src/modules/perl/modperl_common_log.h?rev=1602105&r1=1602104&r2=1602105&view=diff
==============================================================================
--- perl/modperl/trunk/src/modules/perl/modperl_common_log.h (original)
+++ perl/modperl/trunk/src/modules/perl/modperl_common_log.h Thu Jun 12 09:29:09 2014
@@ -58,3 +58,10 @@ void modperl_trace(const char *func, con
 void modperl_trace_level_set(apr_file_t *logfile, const char *level);
 
 #endif /* MODPERL_COMMON_LOG_H */
+
+/*
+ * Local Variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ */

Modified: perl/modperl/trunk/src/modules/perl/modperl_common_types.h
URL: http://svn.apache.org/viewvc/perl/modperl/trunk/src/modules/perl/modperl_common_types.h?rev=1602105&r1=1602104&r2=1602105&view=diff
==============================================================================
--- perl/modperl/trunk/src/modules/perl/modperl_common_types.h (original)
+++ perl/modperl/trunk/src/modules/perl/modperl_common_types.h Thu Jun 12 09:29:09 2014
@@ -26,3 +26,10 @@ typedef struct {
 } modperl_uri_t;
 
 #endif /* MODPERL_COMMON_TYPES_H */
+
+/*
+ * Local Variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ */

Modified: perl/modperl/trunk/src/modules/perl/modperl_common_util.c
URL: http://svn.apache.org/viewvc/perl/modperl/trunk/src/modules/perl/modperl_common_util.c?rev=1602105&r1=1602104&r2=1602105&view=diff
==============================================================================
--- perl/modperl/trunk/src/modules/perl/modperl_common_util.c (original)
+++ perl/modperl/trunk/src/modules/perl/modperl_common_util.c Thu Jun 12 09:29:09 2014
@@ -152,3 +152,10 @@ MP_INLINE modperl_uri_t *modperl_uri_new
     uri->pool = p;
     return uri;
 }
+
+/*
+ * Local Variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ */

Modified: perl/modperl/trunk/src/modules/perl/modperl_common_util.h
URL: http://svn.apache.org/viewvc/perl/modperl/trunk/src/modules/perl/modperl_common_util.h?rev=1602105&r1=1602104&r2=1602105&view=diff
==============================================================================
--- perl/modperl/trunk/src/modules/perl/modperl_common_util.h (original)
+++ perl/modperl/trunk/src/modules/perl/modperl_common_util.h Thu Jun 12 09:29:09 2014
@@ -110,3 +110,10 @@ MP_INLINE modperl_uri_t *modperl_uri_new
 SV *modperl_perl_gensym(pTHX_ char *pack);
 
 #endif /* MODPERL_COMMON_UTIL_H */
+
+/*
+ * Local Variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ */

Modified: perl/modperl/trunk/src/modules/perl/modperl_config.c
URL: http://svn.apache.org/viewvc/perl/modperl/trunk/src/modules/perl/modperl_config.c?rev=1602105&r1=1602104&r2=1602105&view=diff
==============================================================================
--- perl/modperl/trunk/src/modules/perl/modperl_config.c (original)
+++ perl/modperl/trunk/src/modules/perl/modperl_config.c Thu Jun 12 09:29:09 2014
@@ -374,9 +374,14 @@ apr_status_t modperl_config_request_clea
 apr_status_t modperl_config_req_cleanup(void *data)
 {
     request_rec *r = (request_rec *)data;
-    MP_dTHX;
+    apr_status_t rc;
+    MP_dINTERPa(r, NULL, NULL);
 
-    return modperl_config_request_cleanup(aTHX_ r);
+    rc = modperl_config_request_cleanup(aTHX_ r);
+
+    MP_INTERP_PUTBACK(interp, aTHX);
+
+    return rc;
 }
 
 void *modperl_get_perl_module_config(ap_conf_vector_t *cv)
@@ -674,3 +679,10 @@ int modperl_config_is_perl_option_enable
     }
 
 }
+
+/*
+ * Local Variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ */

Modified: perl/modperl/trunk/src/modules/perl/modperl_config.h
URL: http://svn.apache.org/viewvc/perl/modperl/trunk/src/modules/perl/modperl_config.h?rev=1602105&r1=1602104&r2=1602105&view=diff
==============================================================================
--- perl/modperl/trunk/src/modules/perl/modperl_config.h (original)
+++ perl/modperl/trunk/src/modules/perl/modperl_config.h Thu Jun 12 09:29:09 2014
@@ -36,7 +36,7 @@ void *modperl_config_srv_merge(apr_pool_
 char **modperl_config_srv_argv_init(modperl_config_srv_t *scfg, int *argc);
 
 #define modperl_config_srv_argv_push(arg)               \
-    *(const char **)apr_array_push(scfg->argv) = arg
+    *(const char **)apr_array_push(scfg->argv) = (arg)
 
 apr_status_t modperl_config_request_cleanup(pTHX_ request_rec *r);
 
@@ -49,9 +49,9 @@ apr_status_t modperl_config_req_cleanup(
 #define modperl_config_req_cleanup_register(r, rcfg)           \
     if (r && !MpReqCLEANUP_REGISTERED(rcfg)) {                 \
         apr_pool_t *p;                           \
-        apr_pool_create(&p, r->pool);                   \
+        apr_pool_create(&p, (r)->pool);                 \
         apr_pool_cleanup_register(p,                   \
-                                  (void*)r,                    \
+                                  (void*)(r),                  \
                                   modperl_config_req_cleanup,  \
                                   apr_pool_cleanup_null);      \
         MpReqCLEANUP_REGISTERED_On(rcfg);                      \
@@ -62,27 +62,27 @@ void modperl_set_perl_module_config(ap_c
 
 #if defined(MP_IN_XS) && defined(WIN32)
 #   define modperl_get_module_config(v)         \
-    modperl_get_perl_module_config(v)
+    modperl_get_perl_module_config((v))
 
 #   define modperl_set_module_config(v, c)      \
-    modperl_set_perl_module_config(v, c)
+    modperl_set_perl_module_config((v), (c))
 #else
 #   define modperl_get_module_config(v)         \
-    ap_get_module_config(v, &perl_module)
+    ap_get_module_config((v), &perl_module)
 
 #   define modperl_set_module_config(v, c)      \
-    ap_set_module_config(v, &perl_module, c)
+    ap_set_module_config((v), &perl_module, (c))
 #endif
 
 #define modperl_config_req_init(r, rcfg)                    \
-    if (!rcfg) {                                            \
-        rcfg = modperl_config_req_new(r);                   \
-        modperl_set_module_config(r->request_config, rcfg); \
+    if (!(rcfg)) {                                          \
+        (rcfg) = modperl_config_req_new(r);                 \
+        modperl_set_module_config((r)->request_config, (rcfg)); \
     }
 
 #define modperl_config_req_get(r)                               \
     (r ? (modperl_config_req_t *)                               \
-     modperl_get_module_config(r->request_config) : NULL)
+     modperl_get_module_config((r)->request_config) : NULL)
 
 #define MP_dRCFG \
     modperl_config_req_t *rcfg = modperl_config_req_get(r)
@@ -90,23 +90,23 @@ void modperl_set_perl_module_config(ap_c
 #define modperl_config_con_init(c, ccfg)                 \
     if (!ccfg) {                                         \
         ccfg = modperl_config_con_new(c);                \
-        modperl_set_module_config(c->conn_config, ccfg); \
+        modperl_set_module_config((c)->conn_config, (ccfg)); \
     }
 
 #define modperl_config_con_get(c)                               \
     (c ? (modperl_config_con_t *)                               \
-     modperl_get_module_config(c->conn_config) : NULL)
+     modperl_get_module_config((c)->conn_config) : NULL)
 
 #define MP_dCCFG \
     modperl_config_con_t *ccfg = modperl_config_con_get(c)
 
 #define modperl_config_dir_get(r)                               \
     (r ? (modperl_config_dir_t *)                               \
-     modperl_get_module_config(r->per_dir_config) : NULL)
+     modperl_get_module_config((r)->per_dir_config) : NULL)
 
 #define modperl_config_dir_get_defaults(s)              \
     (modperl_config_dir_t *)                            \
-        modperl_get_module_config(s->lookup_defaults)
+        modperl_get_module_config((s)->lookup_defaults)
 
 #define MP_dDCFG \
     modperl_config_dir_t *dcfg = modperl_config_dir_get(r)
@@ -118,24 +118,6 @@ void modperl_set_perl_module_config(ap_c
 #define MP_dSCFG(s)                                             \
     modperl_config_srv_t *scfg = modperl_config_srv_get(s)
 
-#ifdef USE_ITHREADS
-#   define MP_dSCFG_dTHX            \
-    dTHXa(scfg->mip->parent->perl); \
-    PERL_SET_CONTEXT(aTHX)
-#else
-#   define MP_dSCFG_dTHX dTHXa(scfg->perl)
-#endif
-
-/* hopefully this macro will not need to be used often */
-#ifdef USE_ITHREADS
-#   define MP_dTHX                                              \
-    modperl_interp_t *interp =                                  \
-        modperl_interp_select(r, r->connection, r->server);     \
-    dTHXa(interp->perl)
-#else
-#   define MP_dTHX dNOOP
-#endif
-
 int modperl_config_apply_PerlModule(server_rec *s,
                                     modperl_config_srv_t *scfg,
                                     PerlInterpreter *perl, apr_pool_t *p);
@@ -174,3 +156,10 @@ int modperl_config_is_perl_option_enable
 
 
 #endif /* MODPERL_CONFIG_H */
+
+/*
+ * Local Variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ */

Modified: perl/modperl/trunk/src/modules/perl/modperl_const.c
URL: http://svn.apache.org/viewvc/perl/modperl/trunk/src/modules/perl/modperl_const.c?rev=1602105&r1=1602104&r2=1602105&view=diff
==============================================================================
--- perl/modperl/trunk/src/modules/perl/modperl_const.c (original)
+++ perl/modperl/trunk/src/modules/perl/modperl_const.c Thu Jun 12 09:29:09 2014
@@ -131,3 +131,10 @@ XS(XS_modperl_const_compile)
 
     XSRETURN_EMPTY;
 }
+
+/*
+ * Local Variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ */

Modified: perl/modperl/trunk/src/modules/perl/modperl_const.h
URL: http://svn.apache.org/viewvc/perl/modperl/trunk/src/modules/perl/modperl_const.h?rev=1602105&r1=1602104&r2=1602105&view=diff
==============================================================================
--- perl/modperl/trunk/src/modules/perl/modperl_const.h (original)
+++ perl/modperl/trunk/src/modules/perl/modperl_const.h Thu Jun 12 09:29:09 2014
@@ -31,3 +31,10 @@ XS(XS_modperl_const_compile);
          __FILE__)
 
 #endif /* MODPERL_CONST_H */
+
+/*
+ * Local Variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ */

Modified: perl/modperl/trunk/src/modules/perl/modperl_debug.c
URL: http://svn.apache.org/viewvc/perl/modperl/trunk/src/modules/perl/modperl_debug.c?rev=1602105&r1=1602104&r2=1602105&view=diff
==============================================================================
--- perl/modperl/trunk/src/modules/perl/modperl_debug.c (original)
+++ perl/modperl/trunk/src/modules/perl/modperl_debug.c Thu Jun 12 09:29:09 2014
@@ -21,28 +21,6 @@ char *modperl_server_desc(server_rec *s,
     return apr_psprintf(p, "%s:%u", s->server_hostname, s->port);
 }
 
-/* used in debug traces */
-MP_INLINE char *modperl_pid_tid(apr_pool_t *p)
-{
-    if (modperl_threaded_mpm()) {
-        return apr_psprintf(p, "%lu"
-#if APR_HAS_THREADS
-                            "/%lu"
-#endif /* APR_HAS_THREADS */
-                            , (unsigned long)getpid()
-#if APR_HAS_THREADS
-                            , modperl_threads_started()
-                            ? (unsigned long)apr_os_thread_current()
-                            : 0
-#endif /* APR_HAS_THREADS */
-            );
-    }
-    else {
-        return apr_psprintf(p, "%lu", (unsigned long)getpid());
-    }
-}
-
-    
 #ifdef MP_TRACE
 void modperl_apr_table_dump(pTHX_ apr_table_t *table, char *name)
 {
@@ -97,3 +75,10 @@ void modperl_perl_modglobal_dump(pTHX)
 
 }
 #endif
+
+/*
+ * Local Variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ */

Modified: perl/modperl/trunk/src/modules/perl/modperl_debug.h
URL: http://svn.apache.org/viewvc/perl/modperl/trunk/src/modules/perl/modperl_debug.h?rev=1602105&r1=1602104&r2=1602105&view=diff
==============================================================================
--- perl/modperl/trunk/src/modules/perl/modperl_debug.h (original)
+++ perl/modperl/trunk/src/modules/perl/modperl_debug.h Thu Jun 12 09:29:09 2014
@@ -19,8 +19,19 @@
 
 #include "mod_perl.h"
 
+#ifdef MP_DEBUG
+#  define MP_ASSERT(exp) ap_assert(exp)
+#else
+#  define MP_ASSERT(exp) ((void)0)
+#endif
+
+#ifdef USE_ITHREADS
+#  define MP_ASSERT_CONTEXT(perl) MP_ASSERT((perl) == PERL_GET_CONTEXT)
+#else
+#  define MP_ASSERT_CONTEXT(perl) ((void)0)
+#endif
+
 char *modperl_server_desc(server_rec *s, apr_pool_t *p);
-MP_INLINE char *modperl_pid_tid(apr_pool_t *p);
 
 #ifdef MP_TRACE
 void modperl_apr_table_dump(pTHX_ apr_table_t *table, char *name);
@@ -29,3 +40,10 @@ void modperl_perl_modglobal_dump(pTHX);
 #endif
 
 #endif /* MODPERL_DEBUG_H */
+
+/*
+ * Local Variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ */

Modified: perl/modperl/trunk/src/modules/perl/modperl_env.c
URL: http://svn.apache.org/viewvc/perl/modperl/trunk/src/modules/perl/modperl_env.c?rev=1602105&r1=1602104&r2=1602105&view=diff
==============================================================================
--- perl/modperl/trunk/src/modules/perl/modperl_env.c (original)
+++ perl/modperl/trunk/src/modules/perl/modperl_env.c Thu Jun 12 09:29:09 2014
@@ -232,15 +232,15 @@ void modperl_env_configure_server(pTHX_ 
         }
     }
 
-    MP_TRACE_e(MP_FUNC, "\t[%s/0x%lx/%s]"
+    MP_TRACE_e(MP_FUNC, "\t[0x%lx/%s]"
                "\n\t@ENV{keys scfg->SetEnv} = values scfg->SetEnv;",
-               modperl_pid_tid(p), modperl_interp_address(aTHX),
+               modperl_interp_address(aTHX),
                modperl_server_desc(s, p));
     modperl_env_table_populate(aTHX_ scfg->SetEnv);
 
-    MP_TRACE_e(MP_FUNC, "\t[%s/0x%lx/%s]"
+    MP_TRACE_e(MP_FUNC, "\t[0x%lx/%s]"
                "\n\t@ENV{keys scfg->PassEnv} = values scfg->PassEnv;",
-               modperl_pid_tid(p), modperl_interp_address(aTHX),
+               modperl_interp_address(aTHX),
                modperl_server_desc(s, p));
     modperl_env_table_populate(aTHX_ scfg->PassEnv);
 }
@@ -270,9 +270,9 @@ void modperl_env_configure_request_dir(p
          * collisions with per-server PerlSetEnv entries are
          * resolved via the nature of a Perl hash
          */
-        MP_TRACE_e(MP_FUNC, "\t[%s/0x%lx/%s]"
+        MP_TRACE_e(MP_FUNC, "\t[0x%lx/%s]"
                    "\n\t@ENV{keys dcfg->SetEnv} = values dcfg->SetEnv;",
-                   modperl_pid_tid(r->pool), modperl_interp_address(aTHX),
+                   modperl_interp_address(aTHX),
                    modperl_server_desc(r->server, r->pool));
         modperl_env_table_populate(aTHX_ dcfg->SetEnv);
 
@@ -303,9 +303,9 @@ void modperl_env_configure_request_srv(p
      */
 
     if (!apr_is_empty_table(scfg->SetEnv)) {
-        MP_TRACE_e(MP_FUNC, "\t[%s/0x%lx/%s]"
+        MP_TRACE_e(MP_FUNC, "\t[0x%lx/%s]"
                    "\n\t@ENV{keys scfg->SetEnv} = values scfg->SetEnv;",
-                   modperl_pid_tid(r->pool), modperl_interp_address(aTHX),
+                   modperl_interp_address(aTHX),
                    modperl_server_desc(r->server, r->pool));
         modperl_env_table_populate(aTHX_ scfg->SetEnv);
 
@@ -313,9 +313,9 @@ void modperl_env_configure_request_srv(p
     }
 
     if (!apr_is_empty_table(scfg->PassEnv)) {
-        MP_TRACE_e(MP_FUNC, "\t[%s/0x%lx/%s]"
+        MP_TRACE_e(MP_FUNC, "\t[0x%lx/%s]"
                    "\n\t@ENV{keys scfg->PassEnv} = values scfg->PassEnv;",
-                   modperl_pid_tid(r->pool), modperl_interp_address(aTHX),
+                   modperl_interp_address(aTHX),
                    modperl_server_desc(r->server, r->pool));
         modperl_env_table_populate(aTHX_ scfg->PassEnv);
 
@@ -363,9 +363,9 @@ void modperl_env_request_populate(pTHX_ 
      * phases from populating %ENV with new subprocess_env table entries
      */
 
-    MP_TRACE_e(MP_FUNC, "\t[%s/0x%lx/%s%s]"
+    MP_TRACE_e(MP_FUNC, "\t[0x%lx/%s%s]"
                "\n\t@ENV{keys r->subprocess_env} = values r->subprocess_env;",
-               modperl_pid_tid(r->pool), modperl_interp_address(aTHX),
+               modperl_interp_address(aTHX),
                modperl_server_desc(r->server, r->pool), r->uri);
 
     /* we can eliminate some of the cost by only doing CGI variables once
@@ -397,8 +397,8 @@ void modperl_env_request_unpopulate(pTHX
     }
 
     MP_TRACE_e(MP_FUNC,
-               "\n\t[%s/0x%lx/%s%s]\n\tdelete @ENV{keys r->subprocess_env};",
-               modperl_pid_tid(r->pool), modperl_interp_address(aTHX),
+               "\n\t[0x%lx/%s%s]\n\tdelete @ENV{keys r->subprocess_env};",
+               modperl_interp_address(aTHX),
                modperl_server_desc(r->server, r->pool), r->uri);
     modperl_env_table_unpopulate(aTHX_ r->subprocess_env);
 
@@ -411,8 +411,8 @@ void modperl_env_request_tie(pTHX_ reque
     EnvMgLenSet(-1);
 
 #ifdef MP_PERL_HV_GMAGICAL_AWARE
-    MP_TRACE_e(MP_FUNC, "[%s/0x%lx] tie %%ENV, $r\t (%s%s)",
-               modperl_pid_tid(r->pool), modperl_interp_address(aTHX),
+    MP_TRACE_e(MP_FUNC, "[0x%lx] tie %%ENV, $r\t (%s%s)",
+               modperl_interp_address(aTHX),
                modperl_server_desc(r->server, r->pool), r->uri);
     SvGMAGICAL_on((SV*)ENVHV);
 #endif
@@ -423,8 +423,8 @@ void modperl_env_request_untie(pTHX_ req
     EnvMgObjSet(NULL);
 
 #ifdef MP_PERL_HV_GMAGICAL_AWARE
-    MP_TRACE_e(MP_FUNC, "[%s/0x%lx] untie %%ENV; # from r\t (%s%s)",
-               modperl_pid_tid(r->pool), modperl_interp_address(aTHX),
+    MP_TRACE_e(MP_FUNC, "[0x%lx] untie %%ENV; # from r\t (%s%s)",
+               modperl_interp_address(aTHX),
                modperl_server_desc(r->server, r->pool), r->uri);
     SvGMAGICAL_off((SV*)ENVHV);
 #endif
@@ -480,8 +480,7 @@ static int modperl_env_magic_set_all(pTH
                 apr_table_set(r->subprocess_env,
                               hv_iterkey(entry, &keylen),
                               SvPV(hv_iterval((HV*)sv, entry), n_a));
-                MP_TRACE_e(MP_FUNC, "[%s/0x%lx] localizing: %s => %s",
-                           modperl_pid_tid(r->pool),
+                MP_TRACE_e(MP_FUNC, "[0x%lx] localizing: %s => %s",
                            modperl_interp_address(aTHX),
                            hv_iterkey(entry, &keylen),
                            SvPV(hv_iterval((HV*)sv, entry), n_a));
@@ -493,17 +492,14 @@ static int modperl_env_magic_set_all(pTH
         HE *entry;
         STRLEN n_a;
 
-        MP_TRACE_e(MP_FUNC,
-                   "\n\t[%lu/0x%lx] populating %%ENV:",
-                   (unsigned long)getpid(), modperl_interp_address(aTHX));
+        MP_TRACE_e(MP_FUNC, "\n\t[0x%lx] populating %%ENV:",
+                   modperl_interp_address(aTHX));
 
         hv_iterinit((HV*)sv);
 
         while ((entry = hv_iternext((HV*)sv))) {
                 I32 keylen;
                 MP_TRACE_e(MP_FUNC, "$ENV{%s} = \"%s\";",
-                           modperl_pid_tid(r->pool),
-                           modperl_interp_address(aTHX),
                            hv_iterkey(entry, &keylen),
                            SvPV(hv_iterval((HV*)sv, entry), n_a));
             }
@@ -520,14 +516,12 @@ static int modperl_env_magic_clear_all(p
 
     if (r) {
         apr_table_clear(r->subprocess_env);
-        MP_TRACE_e(MP_FUNC,
-                   "[%s/0x%lx] clearing all magic off r->subprocess_env",
-                   modperl_pid_tid(r->pool), modperl_interp_address(aTHX));
+        MP_TRACE_e(MP_FUNC, "[0x%lx] clearing all magic off r->subprocess_env",
+                   modperl_interp_address(aTHX));
     }
     else {
-        MP_TRACE_e(MP_FUNC,
-                   "[%s/0x%lx] %%ENV = ();",
-                   modperl_pid_tid(r->pool), modperl_interp_address(aTHX));
+        MP_TRACE_e(MP_FUNC, "[0x%lx] %%ENV = ();",
+                   modperl_interp_address(aTHX));
         return MP_PL_vtbl_call(env, clear);
     }
 
@@ -542,8 +536,7 @@ static int modperl_env_magic_set(pTHX_ S
         MP_dENV_KEY;
         MP_dENV_VAL;
         apr_table_set(r->subprocess_env, key, val);
-        MP_TRACE_e(MP_FUNC, "[%s/0x%lx] r->subprocess_env set: %s => %s",
-                   modperl_pid_tid(r->pool),
+        MP_TRACE_e(MP_FUNC, "[0x%lx] r->subprocess_env set: %s => %s",
                    modperl_interp_address(aTHX), key, val);
     }
     else {
@@ -551,8 +544,7 @@ static int modperl_env_magic_set(pTHX_ S
         MP_dENV_KEY;
         MP_dENV_VAL;
         MP_TRACE_e(MP_FUNC,
-                   "[%lu/0x%lx] $ENV{%s} = \"%s\";",
-                   (unsigned long)getpid(),
+                   "[0x%lx] $ENV{%s} = \"%s\";",
                    modperl_interp_address(aTHX), key, val);
 #endif
         return MP_PL_vtbl_call(envelem, set);
@@ -568,15 +560,13 @@ static int modperl_env_magic_clear(pTHX_
     if (r) {
         MP_dENV_KEY;
         apr_table_unset(r->subprocess_env, key);
-        MP_TRACE_e(MP_FUNC, "[%s/0x%lx] r->subprocess_env unset: %s",
-                   modperl_pid_tid(r->pool),
+        MP_TRACE_e(MP_FUNC, "[0x%lx] r->subprocess_env unset: %s",
                    modperl_interp_address(aTHX), key);
     }
     else {
 #ifdef MP_TRACE
         MP_dENV_KEY;
-        MP_TRACE_e(MP_FUNC, "[%lu/0x%lx] delete $ENV{%s};",
-                   (unsigned long)getpid(),
+        MP_TRACE_e(MP_FUNC, "[0x%lx] delete $ENV{%s};",
                    modperl_interp_address(aTHX), key);
 #endif
         return MP_PL_vtbl_call(envelem, clear);
@@ -597,15 +587,13 @@ static int modperl_env_magic_get(pTHX_ S
         if ((val = apr_table_get(r->subprocess_env, key))) {
             sv_setpv(sv, val);
             MP_TRACE_e(MP_FUNC,
-                       "[%s/0x%lx] r->subprocess_env get: %s => %s",
-                       modperl_pid_tid(r->pool),
+                       "[0x%lx] r->subprocess_env get: %s => %s",
                        modperl_interp_address(aTHX), key, val);
         }
         else {
             sv_setsv(sv, &PL_sv_undef);
             MP_TRACE_e(MP_FUNC,
-                       "[%s/0x%lx] r->subprocess_env get: %s => undef",
-                       modperl_pid_tid(r->pool),
+                       "[0x%lx] r->subprocess_env get: %s => undef",
                        modperl_interp_address(aTHX), key);
         }
     }
@@ -614,8 +602,7 @@ static int modperl_env_magic_get(pTHX_ S
 #ifdef MP_TRACE
         MP_dENV_KEY;
         MP_TRACE_e(MP_FUNC,
-                   "[%lu/0x%lx] there is no svt_get in PL_vtbl_envelem: %s",
-                   (unsigned long)getpid(),
+                   "[0x%lx] there is no svt_get in PL_vtbl_envelem: %s",
                    modperl_interp_address(aTHX), key);
 #endif
     }
@@ -658,3 +645,10 @@ void modperl_env_unload(void)
     StructCopy(&MP_PERL_vtbl_env, &PL_vtbl_env, MGVTBL);
     StructCopy(&MP_PERL_vtbl_envelem, &PL_vtbl_envelem, MGVTBL);
 }
+
+/*
+ * Local Variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ */

Modified: perl/modperl/trunk/src/modules/perl/modperl_env.h
URL: http://svn.apache.org/viewvc/perl/modperl/trunk/src/modules/perl/modperl_env.h?rev=1602105&r1=1602104&r2=1602105&view=diff
==============================================================================
--- perl/modperl/trunk/src/modules/perl/modperl_env.h (original)
+++ perl/modperl/trunk/src/modules/perl/modperl_env.h Thu Jun 12 09:29:09 2014
@@ -63,3 +63,10 @@ void modperl_env_init(void);
 void modperl_env_unload(void);
 
 #endif /* MODPERL_ENV_H */
+
+/*
+ * Local Variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ */

Modified: perl/modperl/trunk/src/modules/perl/modperl_error.c
URL: http://svn.apache.org/viewvc/perl/modperl/trunk/src/modules/perl/modperl_error.c?rev=1602105&r1=1602104&r2=1602105&view=diff
==============================================================================
--- perl/modperl/trunk/src/modules/perl/modperl_error.c (original)
+++ perl/modperl/trunk/src/modules/perl/modperl_error.c Thu Jun 12 09:29:09 2014
@@ -93,3 +93,10 @@ void modperl_croak(pTHX_ apr_status_t rc
 
     Perl_croak(aTHX_ (char *)NULL);
 }
+
+/*
+ * Local Variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ */

Modified: perl/modperl/trunk/src/modules/perl/modperl_error.h
URL: http://svn.apache.org/viewvc/perl/modperl/trunk/src/modules/perl/modperl_error.h?rev=1602105&r1=1602104&r2=1602105&view=diff
==============================================================================
--- perl/modperl/trunk/src/modules/perl/modperl_error.h (original)
+++ perl/modperl/trunk/src/modules/perl/modperl_error.h Thu Jun 12 09:29:09 2014
@@ -62,3 +62,10 @@ void modperl_croak(pTHX_ apr_status_t rc
     } STMT_END
 
 #endif /* MODPERL_ERROR_H */
+
+/*
+ * Local Variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ */

Modified: perl/modperl/trunk/src/modules/perl/modperl_filter.c
URL: http://svn.apache.org/viewvc/perl/modperl/trunk/src/modules/perl/modperl_filter.c?rev=1602105&r1=1602104&r2=1602105&view=diff
==============================================================================
--- perl/modperl/trunk/src/modules/perl/modperl_filter.c (original)
+++ perl/modperl/trunk/src/modules/perl/modperl_filter.c Thu Jun 12 09:29:09 2014
@@ -282,13 +282,14 @@ static apr_status_t modperl_filter_f_cle
     /* mod_perl filter ctx cleanup */
     if (ctx->data){
 #ifdef USE_ITHREADS
-        dTHXa(ctx->perl);
+        dTHXa(ctx->interp->perl);
+        MP_ASSERT_CONTEXT(aTHX);
 #endif
         if (SvOK(ctx->data) && SvREFCNT(ctx->data)) {
             SvREFCNT_dec(ctx->data);
             ctx->data = NULL;
         }
-        ctx->perl = NULL;
+        MP_INTERP_PUTBACK(ctx->interp, aTHX);
     }
 
     return APR_SUCCESS;
@@ -440,7 +441,7 @@ static int modperl_run_filter_init(ap_fi
     apr_pool_t  *p = r ? r->pool : c->pool;
     modperl_filter_t *filter = modperl_filter_new(f, NULL, mode, 0, 0, 0);
 
-    MP_dINTERP_SELECT(r, c, s);
+    MP_dINTERPa(r, c, s);
 
     MP_TRACE_h(MP_FUNC, "running filter init handler %s",
                modperl_handler_name(handler));
@@ -464,7 +465,7 @@ static int modperl_run_filter_init(ap_fi
     FILTER_FREE(filter);
     SvREFCNT_dec((SV*)args);
 
-    MP_INTERP_PUTBACK(interp);
+    MP_INTERP_PUTBACK(interp, aTHX);
 
     MP_TRACE_f(MP_FUNC, MP_FILTER_NAME_FORMAT
                "return: %d", modperl_handler_name(handler), status);
@@ -485,7 +486,7 @@ int modperl_run_filter(modperl_filter_t 
     server_rec  *s = r ? r->server : c->base_server;
     apr_pool_t  *p = r ? r->pool : c->pool;
 
-    MP_dINTERP_SELECT(r, c, s);
+    MP_dINTERPa(r, c, s);
 
     MP_FILTER_SAVE_ERRSV(errsv);
 
@@ -555,7 +556,7 @@ int modperl_run_filter(modperl_filter_t 
 
     MP_FILTER_RESTORE_ERRSV(errsv);
 
-    MP_INTERP_PUTBACK(interp);
+    MP_INTERP_PUTBACK(interp, aTHX);
 
     MP_TRACE_f(MP_FUNC, MP_FILTER_NAME_FORMAT
                "return: %d", modperl_handler_name(handler), status);
@@ -1291,3 +1292,10 @@ void modperl_brigade_dump(apr_bucket_bri
     }
 #endif
 }
+
+/*
+ * Local Variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ */

Modified: perl/modperl/trunk/src/modules/perl/modperl_filter.h
URL: http://svn.apache.org/viewvc/perl/modperl/trunk/src/modules/perl/modperl_filter.h?rev=1602105&r1=1602104&r2=1602105&view=diff
==============================================================================
--- perl/modperl/trunk/src/modules/perl/modperl_filter.h (original)
+++ perl/modperl/trunk/src/modules/perl/modperl_filter.h Thu Jun 12 09:29:09 2014
@@ -114,3 +114,10 @@ void modperl_filter_runtime_add(pTHX_ re
                                 SV *callback, const char *type);
 
 #endif /* MODPERL_FILTER_H */
+
+/*
+ * Local Variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ */

Modified: perl/modperl/trunk/src/modules/perl/modperl_global.c
URL: http://svn.apache.org/viewvc/perl/modperl/trunk/src/modules/perl/modperl_global.c?rev=1602105&r1=1602104&r2=1602105&view=diff
==============================================================================
--- perl/modperl/trunk/src/modules/perl/modperl_global.c (original)
+++ perl/modperl/trunk/src/modules/perl/modperl_global.c Thu Jun 12 09:29:09 2014
@@ -303,3 +303,10 @@ void modperl_tls_reset_cleanup_##gname(a
 }
 
 MP_TLS_IMPL(request_rec, request_rec *)
+
+/*
+ * Local Variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ */

Modified: perl/modperl/trunk/src/modules/perl/modperl_global.h
URL: http://svn.apache.org/viewvc/perl/modperl/trunk/src/modules/perl/modperl_global.h?rev=1602105&r1=1602104&r2=1602105&view=diff
==============================================================================
--- perl/modperl/trunk/src/modules/perl/modperl_global.h (original)
+++ perl/modperl/trunk/src/modules/perl/modperl_global.h Thu Jun 12 09:29:09 2014
@@ -81,3 +81,10 @@ void modperl_tls_reset_cleanup_##gname(a
 MP_TLS_DECL(request_rec, request_rec *);
 
 #endif /* MODPERL_GLOBAL_H */
+
+/*
+ * Local Variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ */

Modified: perl/modperl/trunk/src/modules/perl/modperl_gtop.c
URL: http://svn.apache.org/viewvc/perl/modperl/trunk/src/modules/perl/modperl_gtop.c?rev=1602105&r1=1602104&r2=1602105&view=diff
==============================================================================
--- perl/modperl/trunk/src/modules/perl/modperl_gtop.c (original)
+++ perl/modperl/trunk/src/modules/perl/modperl_gtop.c Thu Jun 12 09:29:09 2014
@@ -145,3 +145,10 @@ void modperl_gtop_report_proc_mem_after(
 }
 
 #endif /* MP_USE_GTOP */
+
+/*
+ * Local Variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ */

Modified: perl/modperl/trunk/src/modules/perl/modperl_gtop.h
URL: http://svn.apache.org/viewvc/perl/modperl/trunk/src/modules/perl/modperl_gtop.h?rev=1602105&r1=1602104&r2=1602105&view=diff
==============================================================================
--- perl/modperl/trunk/src/modules/perl/modperl_gtop.h (original)
+++ perl/modperl/trunk/src/modules/perl/modperl_gtop.h Thu Jun 12 09:29:09 2014
@@ -72,3 +72,10 @@ void modperl_gtop_report_proc_mem_after(
 #endif /* MP_USE_GTOP */
 
 #endif /* MODPERL_GTOP_H */
+
+/*
+ * Local Variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ */

Modified: perl/modperl/trunk/src/modules/perl/modperl_handler.c
URL: http://svn.apache.org/viewvc/perl/modperl/trunk/src/modules/perl/modperl_handler.c?rev=1602105&r1=1602104&r2=1602105&view=diff
==============================================================================
--- perl/modperl/trunk/src/modules/perl/modperl_handler.c (original)
+++ perl/modperl/trunk/src/modules/perl/modperl_handler.c Thu Jun 12 09:29:09 2014
@@ -39,8 +39,7 @@ modperl_handler_t *modperl_handler_new(a
     /* not necessary due to apr_pcalloc */
     /* handler->cv = NULL; */
     handler->name = name;
-    MP_TRACE_h(MP_FUNC, "[%s] new handler %s",
-               modperl_pid_tid(p), handler->name);
+    MP_TRACE_h(MP_FUNC, "new handler %s", handler->name);
 
     return handler;
 }
@@ -105,8 +104,7 @@ MP_INLINE modperl_mgv_t *modperl_handler
     anon->len  = strlen(anon->name);
     PERL_HASH(anon->hash, anon->name, anon->len);
 
-    MP_TRACE_h(MP_FUNC, "[%s] new anon handler: '%s'",
-               modperl_pid_tid(p), anon->name);
+    MP_TRACE_h(MP_FUNC, "new anon handler: '%s'", anon->name);
     return anon;
 }
 
@@ -175,8 +173,7 @@ modperl_handler_t *modperl_handler_new_a
     handler->cv   = cv;
     handler->name = NULL;
 
-    MP_TRACE_h(MP_FUNC, "[%s] new cached cv anon handler",
-               modperl_pid_tid(p));
+    MP_TRACE_h(MP_FUNC, "new cached cv anon handler");
 #endif
 
     return handler;
@@ -223,9 +220,8 @@ int modperl_handler_resolve(pTHX_ modper
         MpHandlerAUTOLOAD_On(handler);
 
         MP_TRACE_h(MP_FUNC,
-                   "[%s %s] handler %s hasn't yet been resolved, "
-                   "attempting to resolve using %s pool 0x%lx\n",
-                   modperl_pid_tid(p),
+                   "[%s] handler %s hasn't yet been resolved, "
+                   "attempting to resolve using %s pool 0x%lx",
                    modperl_server_desc(s, p),
                    modperl_handler_name(handler),
                    duped ? "current" : "server conf",
@@ -349,9 +345,15 @@ void modperl_handler_make_args(pTHX_ AV 
 #define set_desc(dtype)                                 \
     if (desc) *desc = modperl_handler_desc_##dtype(idx)
 
+/* We should be able to use PERL_GET_CONTEXT here. The rcfg condition
+ * makes sure there is a request being processed. The action > GET part
+ * means it is a $r->set_handlers or $r->push_handlers operation. This
+ * can only happen if called by perl code.
+ */
 #define check_modify(dtype)                                     \
     if ((action > MP_HANDLER_ACTION_GET) && rcfg) {             \
-        MP_dSCFG_dTHX;                                          \
+        dTHXa(PERL_GET_CONTEXT);                                \
+        MP_ASSERT(aTHX+0);                                      \
         Perl_croak(aTHX_ "too late to modify %s handlers",      \
                    modperl_handler_desc_##dtype(idx));          \
     }
@@ -631,3 +633,10 @@ int modperl_handler_perl_add_handlers(pT
 
     return TRUE;
 }
+
+/*
+ * Local Variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ */

Modified: perl/modperl/trunk/src/modules/perl/modperl_handler.h
URL: http://svn.apache.org/viewvc/perl/modperl/trunk/src/modules/perl/modperl_handler.h?rev=1602105&r1=1602104&r2=1602105&view=diff
==============================================================================
--- perl/modperl/trunk/src/modules/perl/modperl_handler.h (original)
+++ perl/modperl/trunk/src/modules/perl/modperl_handler.h Thu Jun 12 09:29:09 2014
@@ -85,3 +85,10 @@ int modperl_handler_perl_add_handlers(pT
                                       modperl_handler_action_e action);
 
 #endif /* MODPERL_HANDLER_H */
+
+/*
+ * Local Variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ */

Modified: perl/modperl/trunk/src/modules/perl/modperl_interp.c
URL: http://svn.apache.org/viewvc/perl/modperl/trunk/src/modules/perl/modperl_interp.c?rev=1602105&r1=1602104&r2=1602105&view=diff
==============================================================================
--- perl/modperl/trunk/src/modules/perl/modperl_interp.c (original)
+++ perl/modperl/trunk/src/modules/perl/modperl_interp.c Thu Jun 12 09:29:09 2014
@@ -38,12 +38,7 @@ void modperl_interp_clone_init(modperl_i
 
     MpInterpCLONED_On(interp);
 
-    PERL_SET_CONTEXT(aTHX);
-
-    /* XXX: hack for bug fixed in 5.6.1 */
-    if (PL_scopestack_ix == 0) {
-        ENTER;
-    }
+    MP_ASSERT_CONTEXT(aTHX);
 
     /* clear @DynaLoader::dl_librefs so we only dlclose() those
      * which are opened by the clone
@@ -61,7 +56,7 @@ modperl_interp_t *modperl_interp_new(mod
     memset(interp, '\0', sizeof(*interp));
 
     interp->mip = mip;
-    interp->refcnt = 0; /* for use by APR::Pool->cleanup_register */
+    interp->refcnt = 0;
 
     if (perl) {
 #ifdef MP_USE_GTOP
@@ -79,14 +74,7 @@ modperl_interp_t *modperl_interp_new(mod
 
         interp->perl = perl_clone(perl, clone_flags);
 
-#if MP_PERL_VERSION(5, 8, 0) && \
-    defined(USE_REENTRANT_API) && defined(HAS_CRYPT_R) && defined(__GLIBC__)
-        {
-            dTHXa(interp->perl);
-            /* workaround 5.8.0 bug */
-            PL_reentrant_buffer->_crypt_struct.current_saltbits = 0;
-        }
-#endif
+        MP_ASSERT_CONTEXT(interp->perl);
 
         {
             PTR_TBL_t *source = modperl_module_config_table_get(perl, FALSE);
@@ -101,7 +89,9 @@ modperl_interp_t *modperl_interp_new(mod
 
         /*
          * we keep the PL_ptr_table past perl_clone so it can be used
-         * within modperl_svptr_table_clone.
+         * within modperl_svptr_table_clone. Perl_sv_dup() uses it.
+         * Don't confuse our svptr_table with Perl's ptr_table. They
+         * are different things, although they use the same type.
          */
         if ((clone_flags & CLONEf_KEEP_PTR_TABLE)) {
             dTHXa(interp->perl);
@@ -268,32 +258,48 @@ void modperl_interp_init(server_rec *s, 
     scfg->mip = mip;
 }
 
+#ifdef MP_TRACE
+static apr_status_t modperl_interp_pool_cleanup(void *data)
+{
+    MP_TRACE_i(MP_FUNC, "unselecting: (0x%lx)->refcnt=%ld",
+               data, ((modperl_interp_t*)data)->refcnt);
+
+    return modperl_interp_unselect(data);
+}
+#endif
+
 apr_status_t modperl_interp_unselect(void *data)
 {
     modperl_interp_t *interp = (modperl_interp_t *)data;
     modperl_interp_pool_t *mip = interp->mip;
 
-    if (interp->refcnt != 0) {
+    MP_ASSERT(interp && MpInterpIN_USE(interp));
+    MP_TRACE_i(MP_FUNC, "unselect(interp=%pp): refcnt=%d",
+               interp, interp->refcnt);
+
+    if (interp->refcnt > 1) {
         --interp->refcnt;
-        MP_TRACE_i(MP_FUNC, "interp=0x%lx, refcnt=%d",
+        MP_TRACE_i(MP_FUNC, "interp=0x%lx, refcnt=%d -- interp still in use",
                    (unsigned long)interp, interp->refcnt);
         return APR_SUCCESS;
     }
 
-    if (interp->request) {
-        /* ithreads + a threaded mpm + PerlInterpScope handler */
-        request_rec *r = interp->request;
-        MP_dRCFG;
-        modperl_config_request_cleanup(interp->perl, r);
-        MpReqCLEANUP_REGISTERED_Off(rcfg);
-    }
-
     MpInterpIN_USE_Off(interp);
-    MpInterpPUTBACK_Off(interp);
 
     modperl_thx_interp_set(interp->perl, NULL);
+#ifdef MP_DEBUG
+    PERL_SET_CONTEXT(NULL);
+#endif
 
-    modperl_tipool_putback_data(mip->tipool, data, interp->num_requests);
+    if (interp == mip->parent) {
+        MP_TRACE_i(MP_FUNC, "parent interp=%pp freed", interp);
+    }
+    else {
+        interp->ccfg->interp = NULL;
+        modperl_tipool_putback_data(mip->tipool, data, interp->num_requests);
+        MP_TRACE_i(MP_FUNC, "interp=%pp freed, tipool(size=%ld, in_use=%ld)",
+                   interp, mip->tipool->size, mip->tipool->in_use);
+    }
 
     return APR_SUCCESS;
 }
@@ -321,13 +327,9 @@ modperl_interp_t *modperl_interp_pool_ge
 }
 
 void modperl_interp_pool_set(apr_pool_t *p,
-                             modperl_interp_t *interp,
-                             int cleanup)
+                             modperl_interp_t *interp)
 {
-    /* same as get_interp but optional cleanup  */
-    (void)apr_pool_userdata_set((void *)interp, MP_INTERP_KEY,
-                                cleanup ? modperl_interp_unselect : NULL,
-                                p);
+    (void)apr_pool_userdata_set((void *)interp, MP_INTERP_KEY, NULL, p);
 }
 
 /*
@@ -339,80 +341,134 @@ modperl_interp_t *modperl_interp_pool_se
                                              server_rec *s)
 {
     int is_startup = (p == s->process->pconf);
-    MP_dSCFG(s);
     modperl_interp_t *interp = NULL;
 
-    if (scfg && (is_startup || !modperl_threaded_mpm())) {
-        MP_TRACE_i(MP_FUNC, "using parent interpreter at %s",
-                   is_startup ? "startup" : "request time (non-threaded MPM)");
-
-        if (!scfg->mip) {
-            /* we get here if directive handlers are invoked
-             * before server merge.
-             */
-            modperl_init_vhost(s, p, NULL);
+    if (is_startup) {
+        MP_dSCFG(s);
+        if (scfg) {
+            MP_TRACE_i(MP_FUNC, "using parent interpreter at startup");
+
             if (!scfg->mip) {
-                /* FIXME: We get here if global "server_rec" == s, scfg->mip
-                 * is not created then. I'm not sure if that's bug or 
-                 * bad/good design decicision. For now just return NULL.
+                /* we get here if directive handlers are invoked
+                 * before server merge.
                  */
-                return NULL;
+                modperl_init_vhost(s, p, NULL);
+                if (!scfg->mip) {
+                    /* FIXME: We get here if global "server_rec" == s, scfg->mip
+                     * is not created then. I'm not sure if that's bug or 
+                     * bad/good design decicision. For now just return NULL.
+                     */
+                    return NULL;
+                }
             }
-        }
-
-        interp = scfg->mip->parent;
-    }
-    else {
-        if (!(interp = modperl_interp_pool_get(p))) {
-            interp = modperl_interp_get(s);
-            modperl_interp_pool_set(p, interp, TRUE);
 
-            MP_TRACE_i(MP_FUNC, "set interp in request time pool 0x%lx",
-                       (unsigned long)p);
+            interp = scfg->mip->parent;
         }
         else {
-            MP_TRACE_i(MP_FUNC, "found interp in request time pool 0x%lx",
-                       (unsigned long)p);
+            if (!(interp = modperl_interp_pool_get(p))) {
+        	interp = modperl_interp_get(s);
+                modperl_interp_pool_set(p, interp);
+
+                MP_TRACE_i(MP_FUNC, "set interp %pp in pconf pool %pp",
+                           interp, p);
+            }
+            else {
+                MP_TRACE_i(MP_FUNC, "found interp %pp in pconf pool %pp",
+                           interp, p);
+            }
         }
-    }
 
-    return interp;
+        MpInterpIN_USE_On(interp);
+        interp->refcnt++;
+        /* set context (THX) for this thread */
+        PERL_SET_CONTEXT(interp->perl);
+        /* let the perl interpreter point back to its interp */
+        modperl_thx_interp_set(interp->perl, interp);
+
+        return interp;
+    }
+    else {
+        request_rec *r;
+        apr_pool_userdata_get((void **)&r, "MODPERL_R", p);
+        MP_ASSERT(r);
+        MP_TRACE_i(MP_FUNC, "found userdata MODPERL_R in pool %#lx as %lx",
+                   (unsigned long)r->pool, (unsigned long)r);
+        return modperl_interp_select(r, NULL, NULL);
+    }
 }
 
 modperl_interp_t *modperl_interp_select(request_rec *r, conn_rec *c,
                                         server_rec *s)
 {
-    MP_dSCFG(s);
-    MP_dRCFG;
-    modperl_config_dir_t *dcfg = modperl_config_dir_get(r);
+    MP_dSCFG((r ? s=r->server : c ? s=c->base_server : s));
+    MP_dDCFG;
+    modperl_config_con_t *ccfg;
     const char *desc = NULL;
     modperl_interp_t *interp = NULL;
     apr_pool_t *p = NULL;
-    int is_subrequest = (r && r->main) ? 1 : 0;
     modperl_interp_scope_e scope;
 
-    if (!modperl_threaded_mpm()) {
-        MP_TRACE_i(MP_FUNC,
-                   "using parent 0x%lx for non-threaded mpm (%s:%d)",
-                   (unsigned long)scfg->mip->parent,
-                   s->server_hostname, s->port);
+    /* What does the following condition mean?
+     * (r || c): if true we are at runtime. There is some kind of request
+     *           being processed.
+     * threaded_mpm: self-explanatory
+     *
+     * Thus, it is true if we are either at initialization time or at runtime
+     * but with prefork-MPM. */
+    if (!((r || c) && modperl_threaded_mpm())) {
+        interp = scfg->mip->parent;
+        MpInterpIN_USE_On(interp);
+        interp->refcnt++;
         /* XXX: if no VirtualHosts w/ PerlOptions +Parent we can skip this */
-        PERL_SET_CONTEXT(scfg->mip->parent->perl);
-        return scfg->mip->parent;
+        PERL_SET_CONTEXT(interp->perl);
+        /* let the perl interpreter point back to its interp */
+        modperl_thx_interp_set(interp->perl, interp);
+
+        MP_TRACE_i(MP_FUNC,
+                   "using parent 0x%pp (perl=0x%pp) for %s:%d refcnt set to %d",
+                   interp, interp->perl, s->server_hostname, s->port,
+                   interp->refcnt);
+        return interp;
     }
 
-    if (rcfg && rcfg->interp) {
-        /* if scope is per-handler and something selected an interpreter
-         * before modperl_callback_run_handlers() and is still holding it,
-         * e.g. modperl_response_handler_cgi(), that interpreter will
-         * be here
-         */
+    if(!c) c = r->connection;
+    ccfg = modperl_config_con_get(c);
+
+    if (ccfg && ccfg->interp) {
+        ccfg->interp->refcnt++;
+
         MP_TRACE_i(MP_FUNC,
-                   "found interp 0x%lx in request config\n",
-                   (unsigned long)rcfg->interp);
-        return rcfg->interp;
+                   "found interp 0x%lx in con config, refcnt incremented to %d",
+                   (unsigned long)ccfg->interp, ccfg->interp->refcnt);
+        /* set context (THX) for this thread */
+        PERL_SET_CONTEXT(ccfg->interp->perl);
+        /* modperl_thx_interp_set() is not called here because the interp
+         * already belongs to the perl interpreter
+         */
+        return ccfg->interp;
     }
 
+    MP_TRACE_i(MP_FUNC,
+               "fetching interp for %s:%d", s->server_hostname, s->port);
+    interp = modperl_interp_get(s);
+    MP_TRACE_i(MP_FUNC, "  --> got %pp (perl=%pp)", interp, interp->perl);
+    ++interp->num_requests; /* should only get here once per request */
+    interp->refcnt = 0;
+
+    /* set context (THX) for this thread */
+    PERL_SET_CONTEXT(interp->perl);
+    /* let the perl interpreter point back to its interp */
+    modperl_thx_interp_set(interp->perl, interp);
+
+    /* make sure ccfg is initialized */
+    modperl_config_con_init(c, ccfg);
+    ccfg->interp = interp;
+    interp->ccfg = ccfg;
+
+    MP_TRACE_i(MP_FUNC,
+               "pulled interp %pp (perl=%pp) from mip, num_requests is %d",
+               interp, interp->perl, interp->num_requests);
+
     /*
      * if a per-dir PerlInterpScope is specified, use it.
      * else if r != NULL use per-server PerlInterpScope
@@ -426,102 +482,49 @@ modperl_interp_t *modperl_interp_select(
     MP_TRACE_i(MP_FUNC, "scope is per-%s",
                modperl_interp_scope_desc(scope));
 
-    /*
-     * XXX: goto modperl_interp_get() if scope == handler ?
-     */
-
-    if (c && (scope == MP_INTERP_SCOPE_CONNECTION)) {
-        desc = "conn_rec pool";
-        get_interp(c->pool);
-
-        if (interp) {
-            MP_TRACE_i(MP_FUNC,
-                       "found interp 0x%lx in %s 0x%lx\n",
-                       (unsigned long)interp, desc, (unsigned long)c->pool);
-            return interp;
+    if (scope != MP_INTERP_SCOPE_HANDLER) {
+        desc = NULL;
+        if (c && (scope == MP_INTERP_SCOPE_CONNECTION || !r)) {
+            p = c->pool;
+            desc = "connection";
         }
-
-        p = c->pool;
-    }
-    else if (r) {
-        if (is_subrequest && (scope == MP_INTERP_SCOPE_REQUEST)) {
-            /* share 1 interpreter across sub-requests */
+        else if (r) {
             request_rec *main_r = r->main;
 
-            while (main_r && !interp) {
-                p = main_r->pool;
-                get_interp(p);
-                MP_TRACE_i(MP_FUNC,
-                           "looking for interp in main request for %s...%s\n",
-                           main_r->uri, interp ? "found" : "not found");
-                main_r = main_r->main;
+            if (main_r && (scope == MP_INTERP_SCOPE_REQUEST)) {
+                /* share 1 interpreter across sub-requests */
+                for(; main_r; main_r = main_r->main) {
+                    p = main_r->pool;
+                }
+                desc = "main request";
             }
-        }
-        else {
-            p = r->pool;
-            get_interp(p);
-        }
-
-        desc = "request_rec pool";
-
-        if (interp) {
-            MP_TRACE_i(MP_FUNC,
-                       "found interp 0x%lx in %s 0x%lx (%s request for %s)\n",
-                       (unsigned long)interp, desc, (unsigned long)p,
-                       (is_subrequest ? "sub" : "main"), r->uri);
-            return interp;
-        }
-
-        /* might have already been set by a ConnectionHandler */
-        get_interp(r->connection->pool);
-
-        if (interp) {
-            desc = "r->connection pool";
-            MP_TRACE_i(MP_FUNC,
-                       "found interp 0x%lx in %s 0x%lx\n",
-                       (unsigned long)interp, desc,
-                       (unsigned long)r->connection->pool);
-            return interp;
-        }
-    }
-
-    interp = modperl_interp_get(s ? s : r->server);
-    ++interp->num_requests; /* should only get here once per request */
-
-    if (scope == MP_INTERP_SCOPE_HANDLER) {
-        /* caller is responsible for calling modperl_interp_unselect() */
-        interp->request = r;
-        MpReqCLEANUP_REGISTERED_On(rcfg);
-        MpInterpPUTBACK_On(interp);
-    }
-    else {
-        if (!p) {
-            /* should never happen */
-            MP_TRACE_i(MP_FUNC, "no pool");
-            return NULL;
-        }
+            else {
+                p = r->pool;
+                desc = scope == MP_INTERP_SCOPE_REQUEST
+                       ? "main request"
+                       : "sub request";
+            }
+	}
 
-        set_interp(p);
+        MP_ASSERT(p);
 
-#if AP_MODULE_MAGIC_AT_LEAST(20111130, 0)
-        MP_TRACE_i(MP_FUNC,
-                   "set interp 0x%lx in %s 0x%lx (%s request for %s)\n",
-                   (unsigned long)interp, desc, (unsigned long)p,
-                   (r ? (is_subrequest ? "sub" : "main") : "conn"),
-                   (r ? r->uri : c->client_ip));
+#ifdef MP_TRACE
+        apr_pool_cleanup_register(p, (void *)interp,
+                                  modperl_interp_pool_cleanup,
+                                  modperl_interp_pool_cleanup);
 #else
-        MP_TRACE_i(MP_FUNC,
-                   "set interp 0x%lx in %s 0x%lx (%s request for %s)\n",
-                   (unsigned long)interp, desc, (unsigned long)p,
-                   (r ? (is_subrequest ? "sub" : "main") : "conn"),
-                   (r ? r->uri : c->remote_ip));
+        apr_pool_cleanup_register(p, (void *)interp,
+                                  modperl_interp_unselect,
+                                  modperl_interp_unselect);
 #endif
-    }
 
-    /* set context (THX) for this thread */
-    PERL_SET_CONTEXT(interp->perl);
+        /* add a reference for the registered cleanup */
+        interp->refcnt++;
 
-    modperl_thx_interp_set(interp->perl, interp);
+        MP_TRACE_i(MP_FUNC,
+                   "registered unselect cleanup for interp 0x%lx in %s",
+                   (unsigned long)interp, desc);
+    }
 
     return interp;
 }
@@ -591,20 +594,20 @@ void modperl_interp_mip_walk_servers(Per
 }
 
 #define MP_THX_INTERP_KEY "modperl2::thx_interp_key"
-modperl_interp_t *modperl_thx_interp_get(PerlInterpreter *thx)
+modperl_interp_t *modperl_thx_interp_get(pTHX)
 {
     modperl_interp_t *interp;
-    dTHXa(thx);
-    SV **svp = hv_fetch(PL_modglobal, MP_THX_INTERP_KEY, strlen(MP_THX_INTERP_KEY), 0);
+    SV **svp = hv_fetch(PL_modglobal, MP_THX_INTERP_KEY,
+                        strlen(MP_THX_INTERP_KEY), 0);
     if (!svp) return NULL;
     interp = INT2PTR(modperl_interp_t *, SvIV(*svp));
     return interp;
 }
 
-void modperl_thx_interp_set(PerlInterpreter *thx, modperl_interp_t *interp)
+void modperl_thx_interp_set(pTHX_ modperl_interp_t *interp)
 {
-    dTHXa(thx);
-    (void)hv_store(PL_modglobal, MP_THX_INTERP_KEY, strlen(MP_THX_INTERP_KEY), newSViv(PTR2IV(interp)), 0);
+    (void)hv_store(PL_modglobal, MP_THX_INTERP_KEY, strlen(MP_THX_INTERP_KEY),
+                   newSViv(PTR2IV(interp)), 0);
     return;
 }
 
@@ -623,3 +626,10 @@ apr_status_t modperl_interp_cleanup(void
 }
 
 #endif /* USE_ITHREADS */
+
+/*
+ * Local Variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ */

Modified: perl/modperl/trunk/src/modules/perl/modperl_interp.h
URL: http://svn.apache.org/viewvc/perl/modperl/trunk/src/modules/perl/modperl_interp.h?rev=1602105&r1=1602104&r2=1602105&view=diff
==============================================================================
--- perl/modperl/trunk/src/modules/perl/modperl_interp.h (original)
+++ perl/modperl/trunk/src/modules/perl/modperl_interp.h Thu Jun 12 09:29:09 2014
@@ -43,8 +43,7 @@ apr_status_t modperl_interp_unselect(voi
 modperl_interp_t *modperl_interp_pool_get(apr_pool_t *p);
 
 void modperl_interp_pool_set(apr_pool_t *p,
-                             modperl_interp_t *interp,
-                             int cleanup);
+                             modperl_interp_t *interp);
 
 modperl_interp_t *modperl_interp_pool_select(apr_pool_t *p,
                                              server_rec *s);
@@ -52,16 +51,60 @@ modperl_interp_t *modperl_interp_pool_se
 modperl_interp_t *modperl_interp_select(request_rec *r, conn_rec *c,
                                         server_rec *s);
 
-#define MP_dINTERP_SELECT(r, c, s) \
-    pTHX; \
-    modperl_interp_t *interp = NULL; \
-    interp = modperl_interp_select(r, c, s); \
-    aTHX = interp->perl
-
-#define MP_INTERP_PUTBACK(interp) \
-    if (interp && MpInterpPUTBACK(interp)) { \
-        modperl_interp_unselect(interp); \
-    }
+#define MP_dINTERP pTHX; modperl_interp_t *interp = NULL
+
+#define MP_INTERPa(r, c, s)                                             \
+    MP_TRACE_i(MP_FUNC, "selecting interp: r=%pp, c=%pp, s=%pp",        \
+               (r), (c), (s));                                          \
+    interp = modperl_interp_select((r), (c), (s));                      \
+    if (interp) {                                                       \
+        MP_TRACE_i(MP_FUNC, "  --> got (0x%pp)->refcnt=%d, perl=%pp",   \
+                   interp, interp->refcnt, interp->perl);               \
+        aTHX = interp->perl;                                            \
+    }                                                                   \
+    else {                                                              \
+        MP_TRACE_i(MP_FUNC, "  --> failed");                            \
+    }                                                                   \
+    NOOP
+
+#define MP_dINTERPa(r, c, s)                                            \
+    MP_dINTERP;                                                         \
+    MP_INTERPa((r), (c), (s))
+
+#define MP_INTERP_POOLa(p, s)                                           \
+    MP_TRACE_i(MP_FUNC, "selecting interp: p=%pp, s=%pp", (p), (s));    \
+    interp = modperl_interp_pool_select((p), (s));                      \
+    if (interp) {                                                       \
+        MP_TRACE_i(MP_FUNC, "  --> got (0x%pp)->refcnt=%d",             \
+                   interp, interp->refcnt);                             \
+        aTHX = interp->perl;                                            \
+    }                                                                   \
+    else {                                                              \
+        MP_TRACE_i(MP_FUNC, "  --> failed");                            \
+    }                                                                   \
+    NOOP
+
+#define MP_dINTERP_POOLa(p, s)                                          \
+    MP_dINTERP;                                                         \
+    MP_INTERP_POOLa((p), (s))
+
+#ifdef MP_DEBUG
+#define MP_INTERP_PUTBACK(interp, thx)                                  \
+    MP_TRACE_i(MP_FUNC, "unselecting interp: (0x%pp)->refcnt=%ld",      \
+               (interp), (interp)->refcnt);                             \
+    modperl_interp_unselect(interp);                                    \
+    interp = NULL;                                                      \
+    if( thx ) thx = NULL
+#else  /* MP_DEBUG */
+#define MP_INTERP_PUTBACK(interp, thx)                                  \
+    modperl_interp_unselect(interp)
+#endif
+
+#define MP_INTERP_REFCNT_inc(interp) (interp)->refcnt++
+
+#define MP_INTERP_REFCNT_dec(interp) MP_INTERP_PUTBACK(interp, NULL)
+
+#define MP_HAS_INTERP(interp) (interp != NULL)
 
 #define MP_aTHX aTHX
 
@@ -83,12 +126,33 @@ void modperl_interp_mip_walk_servers(Per
                                      void *data);
 #else
 
-#define MP_dINTERP_SELECT(r, c, s) dNOOP
+#define MP_dINTERP dNOOP
+
+#define MP_INTERPa(r, c, s) NOOP
+
+#define MP_dINTERPa(r, c, s) NOOP
 
-#define MP_INTERP_PUTBACK(interp) NOOP
+#define MP_INTERP_POOLa(p, s) NOOP
+
+#define MP_dINTERP_POOLa(p, s) NOOP
+
+#define MP_INTERP_PUTBACK(interp, thx) NOOP
+
+#define MP_INTERP_REFCNT_inc(interp) NOOP
+
+#define MP_INTERP_REFCNT_dec(interp) NOOP
+
+#define MP_HAS_INTERP(interp) (1)
 
 #define MP_aTHX 0
 
 #endif /* USE_ITHREADS */
 
 #endif /* MODPERL_INTERP_H */
+
+/*
+ * Local Variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ */

Modified: perl/modperl/trunk/src/modules/perl/modperl_io.c
URL: http://svn.apache.org/viewvc/perl/modperl/trunk/src/modules/perl/modperl_io.c?rev=1602105&r1=1602104&r2=1602105&view=diff
==============================================================================
--- perl/modperl/trunk/src/modules/perl/modperl_io.c (original)
+++ perl/modperl/trunk/src/modules/perl/modperl_io.c Thu Jun 12 09:29:09 2014
@@ -175,3 +175,9 @@ MP_INLINE void modperl_io_perlio_restore
     modperl_io_perlio_restore_stdhandle(aTHX_ O_WRONLY);
 }
 
+/*
+ * Local Variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ */

Modified: perl/modperl/trunk/src/modules/perl/modperl_io.h
URL: http://svn.apache.org/viewvc/perl/modperl/trunk/src/modules/perl/modperl_io.h?rev=1602105&r1=1602104&r2=1602105&view=diff
==============================================================================
--- perl/modperl/trunk/src/modules/perl/modperl_io.h (original)
+++ perl/modperl/trunk/src/modules/perl/modperl_io.h Thu Jun 12 09:29:09 2014
@@ -75,3 +75,10 @@ MP_INLINE void modperl_io_perlio_restore
 
 
 #endif /* MODPERL_IO_H */
+
+/*
+ * Local Variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ */

Modified: perl/modperl/trunk/src/modules/perl/modperl_io_apache.c
URL: http://svn.apache.org/viewvc/perl/modperl/trunk/src/modules/perl/modperl_io_apache.c?rev=1602105&r1=1602104&r2=1602105&view=diff
==============================================================================
--- perl/modperl/trunk/src/modules/perl/modperl_io_apache.c (original)
+++ perl/modperl/trunk/src/modules/perl/modperl_io_apache.c Thu Jun 12 09:29:09 2014
@@ -334,3 +334,10 @@ MP_INLINE SSize_t modperl_request_read(p
 
     return total;
 }
+
+/*
+ * Local Variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ */

Modified: perl/modperl/trunk/src/modules/perl/modperl_io_apache.h
URL: http://svn.apache.org/viewvc/perl/modperl/trunk/src/modules/perl/modperl_io_apache.h?rev=1602105&r1=1602104&r2=1602105&view=diff
==============================================================================
--- perl/modperl/trunk/src/modules/perl/modperl_io_apache.h (original)
+++ perl/modperl/trunk/src/modules/perl/modperl_io_apache.h Thu Jun 12 09:29:09 2014
@@ -58,3 +58,10 @@ MP_INLINE SSize_t modperl_request_read(p
                                        char *buffer, Size_t len);
 
 #endif /* MODPERL_IO_APACHE_H */
+
+/*
+ * Local Variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ */

Modified: perl/modperl/trunk/src/modules/perl/modperl_log.c
URL: http://svn.apache.org/viewvc/perl/modperl/trunk/src/modules/perl/modperl_log.c?rev=1602105&r1=1602104&r2=1602105&view=diff
==============================================================================
--- perl/modperl/trunk/src/modules/perl/modperl_log.c (original)
+++ perl/modperl/trunk/src/modules/perl/modperl_log.c Thu Jun 12 09:29:09 2014
@@ -15,3 +15,10 @@
  */
 
 #include "modperl_log.h"
+
+/*
+ * Local Variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ */

Modified: perl/modperl/trunk/src/modules/perl/modperl_log.h
URL: http://svn.apache.org/viewvc/perl/modperl/trunk/src/modules/perl/modperl_log.h?rev=1602105&r1=1602104&r2=1602105&view=diff
==============================================================================
--- perl/modperl/trunk/src/modules/perl/modperl_log.h (original)
+++ perl/modperl/trunk/src/modules/perl/modperl_log.h Thu Jun 12 09:29:09 2014
@@ -45,3 +45,10 @@
                  msg)
 
 #endif /* MODPERL_LOG_H */
+
+/*
+ * Local Variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ */

Modified: perl/modperl/trunk/src/modules/perl/modperl_mgv.c
URL: http://svn.apache.org/viewvc/perl/modperl/trunk/src/modules/perl/modperl_mgv.c?rev=1602105&r1=1602104&r2=1602105&view=diff
==============================================================================
--- perl/modperl/trunk/src/modules/perl/modperl_mgv.c (original)
+++ perl/modperl/trunk/src/modules/perl/modperl_mgv.c Thu Jun 12 09:29:09 2014
@@ -211,14 +211,12 @@ int modperl_mgv_resolve(pTHX_ modperl_ha
         handler->name    = NULL;
         handler->mgv_obj = modperl_handler_anon_next(aTHX_ p);
         modperl_handler_anon_add(aTHX_ handler->mgv_obj, cv);
-        MP_TRACE_h(MP_FUNC, "[%s] new anon handler",
-                   modperl_pid_tid(p));
+        MP_TRACE_h(MP_FUNC, "new anon handler");
 #else
         SvREFCNT_inc(cv);
         handler->cv      = cv;
         handler->name    = NULL;
-        MP_TRACE_h(MP_FUNC, "[%s] new cached-cv anon handler",
-                   modperl_pid_tid(p));
+        MP_TRACE_h(MP_FUNC, "new cached-cv anon handler");
 #endif
 
         FREETMPS;LEAVE;
@@ -340,8 +338,7 @@ int modperl_mgv_resolve(pTHX_ modperl_ha
         modperl_mgv_append(aTHX_ p, handler->mgv_cv, handler_name);
 
         MpHandlerPARSED_On(handler);
-        MP_TRACE_h(MP_FUNC, "[%s] found `%s' in class `%s' as a %s",
-                   modperl_pid_tid(p),
+        MP_TRACE_h(MP_FUNC, "found `%s' in class `%s' as a %s",
                    handler_name, HvNAME(stash),
                    MpHandlerMETHOD(handler) ? "method" : "function");
         MODPERL_MGV_DEEP_RESOLVE(handler, p);
@@ -479,10 +476,7 @@ static int modperl_hash_handlers_dir(apr
 {
     int i;
     modperl_config_dir_t *dir_cfg = (modperl_config_dir_t *)cfg;
-#ifdef USE_ITHREADS
-    MP_dSCFG(s);
-    MP_dSCFG_dTHX;
-#endif
+    dTHXa(data);
 
     if (!dir_cfg) {
         return 1;
@@ -500,7 +494,7 @@ static int modperl_hash_handlers_srv(apr
 {
     int i;
     modperl_config_srv_t *scfg = (modperl_config_srv_t *)cfg;
-    MP_dSCFG_dTHX;
+    dTHXa(data);
 
     for (i=0; i < MP_HANDLER_NUM_PER_SRV; i++) {
         modperl_hash_handlers(aTHX_ p, s,
@@ -527,7 +521,21 @@ static int modperl_hash_handlers_srv(apr
 
 void modperl_mgv_hash_handlers(apr_pool_t *p, server_rec *s)
 {
-    ap_pcw_walk_config(p, s, &perl_module, NULL,
+    MP_dINTERPa(NULL, NULL, s);
+    ap_pcw_walk_config(p, s, &perl_module,
+#ifdef USE_ITHREADS
+                       aTHX,
+#else
+                       NULL,
+#endif
                        modperl_hash_handlers_dir,
                        modperl_hash_handlers_srv);
+    MP_INTERP_PUTBACK(interp, aTHX);
 }
+
+/*
+ * Local Variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ */

Modified: perl/modperl/trunk/src/modules/perl/modperl_mgv.h
URL: http://svn.apache.org/viewvc/perl/modperl/trunk/src/modules/perl/modperl_mgv.h?rev=1602105&r1=1602104&r2=1602105&view=diff
==============================================================================
--- perl/modperl/trunk/src/modules/perl/modperl_mgv.h (original)
+++ perl/modperl/trunk/src/modules/perl/modperl_mgv.h Thu Jun 12 09:29:09 2014
@@ -56,3 +56,10 @@ void modperl_mgv_hash_handlers(apr_pool_
 GvCV(sv)
 
 #endif /* MODPERL_MGV_H */
+
+/*
+ * Local Variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ */

Modified: perl/modperl/trunk/src/modules/perl/modperl_module.c
URL: http://svn.apache.org/viewvc/perl/modperl/trunk/src/modules/perl/modperl_module.c?rev=1602105&r1=1602104&r2=1602105&view=diff
==============================================================================
--- perl/modperl/trunk/src/modules/perl/modperl_module.c (original)
+++ perl/modperl/trunk/src/modules/perl/modperl_module.c Thu Jun 12 09:29:09 2014
@@ -103,7 +103,9 @@ PTR_TBL_t *modperl_module_config_table_g
 }
 
 typedef struct {
-    PerlInterpreter *perl;
+#ifdef USE_ITHREADS
+    modperl_interp_t *interp;
+#endif
     PTR_TBL_t *table;
     void *ptr;
 } config_obj_cleanup_t;
@@ -116,13 +118,17 @@ static apr_status_t modperl_module_confi
 {
     config_obj_cleanup_t *cleanup =
         (config_obj_cleanup_t *)data;
-    dTHXa(cleanup->perl);
+#ifdef USE_ITHREADS
+    dTHXa(cleanup->interp->perl);
+    MP_ASSERT_CONTEXT(aTHX);
+#endif
 
     modperl_svptr_table_delete(aTHX_ cleanup->table, cleanup->ptr);
 
-    MP_TRACE_c(MP_FUNC, "deleting ptr 0x%lx from table 0x%lx",
-               (unsigned long)cleanup->ptr,
-               (unsigned long)cleanup->table);
+    MP_TRACE_c(MP_FUNC, "deleting ptr %pp from table %pp",
+               cleanup->ptr, cleanup->table);
+
+    MP_INTERP_PUTBACK(cleanup->interp, aTHX);
 
     return APR_SUCCESS;
 }
@@ -138,7 +144,8 @@ static void modperl_module_config_obj_cl
     cleanup->table = table;
     cleanup->ptr = ptr;
 #ifdef USE_ITHREADS
-    cleanup->perl = aTHX;
+    cleanup->interp = modperl_thx_interp_get(aTHX);
+    MP_INTERP_REFCNT_inc(cleanup->interp);
 #endif
 
     apr_pool_cleanup_register(p, cleanup,
@@ -166,10 +173,7 @@ static void *modperl_module_config_merge
     int is_startup;
     PTR_TBL_t *table;
     SV *mrg_obj = (SV *)NULL, *base_obj, *add_obj;
-#ifdef USE_ITHREADS
-    modperl_interp_t *interp;
-    MP_PERL_CONTEXT_DECLARE;
-#endif
+    MP_dINTERP;
 
     /* if the module is loaded in vhost, base==NULL */
     tmp = (base && base->server) ? base : add;
@@ -182,21 +186,14 @@ static void *modperl_module_config_merge
     s = tmp->server;
     is_startup = (p == s->process->pconf);
 
-#ifdef USE_ITHREADS
-    interp = modperl_interp_pool_select(p, s);
-    MP_PERL_CONTEXT_STORE_OVERRIDE(interp->perl);
-#endif
+    MP_INTERP_POOLa(p, s);
 
     table = modperl_module_config_table_get(aTHX_ TRUE);
     base_obj = modperl_svptr_table_fetch(aTHX_ table, base);
     add_obj  = modperl_svptr_table_fetch(aTHX_ table, add);
 
     if (!base_obj || (base_obj == add_obj)) {
-#ifdef USE_ITHREADS
-        /* XXX: breaks prefork
-           modperl_interp_unselect(interp); */
-        MP_PERL_CONTEXT_RESTORE;
-#endif
+        MP_INTERP_PUTBACK(interp, aTHX);
         return addv;
     }
 
@@ -245,11 +242,7 @@ static void *modperl_module_config_merge
         modperl_module_config_obj_cleanup_register(aTHX_ p, table, mrg);
     }
 
-#ifdef USE_ITHREADS
-    /* XXX: breaks prefork
-       modperl_interp_unselect(interp); */
-    MP_PERL_CONTEXT_RESTORE;
-#endif
+    MP_INTERP_PUTBACK(interp, aTHX);
 
     return (void *)mrg;
 }
@@ -363,16 +356,12 @@ static const char *modperl_module_cmd_ta
     modperl_module_info_t *minfo = MP_MODULE_INFO(info->modp);
     modperl_module_cfg_t *srv_cfg;
     int modules_alias = 0;
-
-#ifdef USE_ITHREADS
-    modperl_interp_t *interp = modperl_interp_pool_select(p, s);
-    dTHXa(interp->perl);
-#endif
-
     int count;
-    PTR_TBL_t *table = modperl_module_config_table_get(aTHX_ TRUE);
+    PTR_TBL_t *table;
     SV *obj = (SV *)NULL;
-    dSP;
+    MP_dINTERP_POOLa(p, s);
+
+    table = modperl_module_config_table_get(aTHX_ TRUE);
 
     if (s->is_virtual) {
         MP_dSCFG(s);
@@ -416,6 +405,7 @@ static const char *modperl_module_cmd_ta
                                               parms, &obj);
 
     if (errmsg) {
+        MP_INTERP_PUTBACK(interp, aTHX);
         return errmsg;
     }
 
@@ -436,6 +426,7 @@ static const char *modperl_module_cmd_ta
                                                minfo->srv_create,
                                                parms, &srv_obj);
         if (errmsg) {
+            MP_INTERP_PUTBACK(interp, aTHX);
             return errmsg;
         }
 
@@ -446,37 +437,42 @@ static const char *modperl_module_cmd_ta
         }
     }
 
-    ENTER;SAVETMPS;
-    PUSHMARK(SP);
-    EXTEND(SP, 2);
+    {
+        dSP;
+        ENTER;SAVETMPS;
+        PUSHMARK(SP);
+        EXTEND(SP, 2);
 
-    PUSHs(obj);
-    PUSHs(modperl_bless_cmd_parms(parms));
+        PUSHs(obj);
+        PUSHs(modperl_bless_cmd_parms(parms));
 
-    if (cmd->args_how != NO_ARGS) {
-        PUSH_STR_ARG(one);
-        PUSH_STR_ARG(two);
-        PUSH_STR_ARG(three);
-    }
+        if (cmd->args_how != NO_ARGS) {
+            PUSH_STR_ARG(one);
+            PUSH_STR_ARG(two);
+            PUSH_STR_ARG(three);
+        }
 
-    PUTBACK;
-    count = call_method(info->func_name, G_EVAL|G_SCALAR);
-    SPAGAIN;
+        PUTBACK;
+        count = call_method(info->func_name, G_EVAL|G_SCALAR);
+        SPAGAIN;
 
-    if (count == 1) {
-        SV *sv = POPs;
-        if (SvPOK(sv) && strEQ(SvPVX(sv), DECLINE_CMD)) {
-            retval = DECLINE_CMD;
+        if (count == 1) {
+            SV *sv = POPs;
+            if (SvPOK(sv) && strEQ(SvPVX(sv), DECLINE_CMD)) {
+                retval = DECLINE_CMD;
+            }
         }
-    }
 
-    PUTBACK;
-    FREETMPS;LEAVE;
+        PUTBACK;
+        FREETMPS;LEAVE;
+    }
 
     if (SvTRUE(ERRSV)) {
         retval = SvPVX(ERRSV);
     }
 
+    MP_INTERP_PUTBACK(interp, aTHX);
+
     if (modules_alias) {
         MP_dSCFG(s);
         /* unalias the temp aliasing */
@@ -644,10 +640,7 @@ static const char *modperl_module_add_cm
     command_rec *cmd;
     AV *module_cmds;
     I32 i, fill;
-#ifdef USE_ITHREADS
-    MP_dSCFG(s);
-    dTHXa(scfg->mip->parent->perl);
-#endif
+    MP_dINTERPa(NULL, NULL, s);
     module_cmds = (AV*)SvRV(mod_cmds);
 
     fill = AvFILL(module_cmds);
@@ -664,6 +657,7 @@ static const char *modperl_module_add_cm
         cmd = apr_array_push(cmds);
 
         if ((errmsg = modperl_module_cmd_fetch(aTHX_ obj, "name", &val))) {
+            MP_INTERP_PUTBACK(interp, aTHX);
             return errmsg;
         }
 
@@ -684,6 +678,7 @@ static const char *modperl_module_add_cm
         }
 
         if (!modperl_module_cmd_lookup(cmd)) {
+            MP_INTERP_PUTBACK(interp, aTHX);
             return apr_psprintf(p,
                                 "no command function defined for args_how=%d",
                                 cmd->args_how);
@@ -736,6 +731,7 @@ static const char *modperl_module_add_cm
 
     modp->cmds = (command_rec *)cmds->elts;
 
+    MP_INTERP_PUTBACK(interp, aTHX);
     return NULL;
 }
 
@@ -783,13 +779,12 @@ const char *modperl_module_add(apr_pool_
                                const char *name, SV *mod_cmds)
 {
     MP_dSCFG(s);
-#ifdef USE_ITHREADS
-    dTHXa(scfg->mip->parent->perl);
-#endif
     const char *errmsg;
-    module *modp = (module *)apr_pcalloc(p, sizeof(*modp));
-    modperl_module_info_t *minfo =
-        (modperl_module_info_t *)apr_pcalloc(p, sizeof(*minfo));
+    module *modp;
+    modperl_module_info_t *minfo;
+    MP_dINTERPa(NULL, NULL, s);
+    modp = (module *)apr_pcalloc(p, sizeof(*modp));
+    minfo = (modperl_module_info_t *)apr_pcalloc(p, sizeof(*minfo));
 
     /* STANDARD20_MODULE_STUFF */
     modp->version       = MODULE_MAGIC_NUMBER_MAJOR;
@@ -827,6 +822,7 @@ const char *modperl_module_add(apr_pool_
     modp->cmds = NULL;
 
     if ((errmsg = modperl_module_add_cmds(p, s, modp, mod_cmds))) {
+        MP_INTERP_PUTBACK(interp, aTHX);
         return errmsg;
     }
 
@@ -855,10 +851,13 @@ const char *modperl_module_add(apr_pool_
      */
     if (!modperl_interp_pool_get(p)) {
         /* for vhosts */
-        modperl_interp_pool_set(p, scfg->mip->parent, FALSE);
+        MP_TRACE_i(MP_FUNC, "set interp 0x%lx in pconf pool 0x%lx",
+                   (unsigned long)scfg->mip->parent, (unsigned long)p);
+        modperl_interp_pool_set(p, scfg->mip->parent);
     }
 #endif
 
+    MP_INTERP_PUTBACK(interp, aTHX);
     return NULL;
 }
 
@@ -903,3 +902,10 @@ SV *modperl_module_config_get_obj(pTHX_ 
 
     return obj;
 }
+
+/*
+ * Local Variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ */

Modified: perl/modperl/trunk/src/modules/perl/modperl_module.h
URL: http://svn.apache.org/viewvc/perl/modperl/trunk/src/modules/perl/modperl_module.h?rev=1602105&r1=1602104&r2=1602105&view=diff
==============================================================================
--- perl/modperl/trunk/src/modules/perl/modperl_module.h (original)
+++ perl/modperl/trunk/src/modules/perl/modperl_module.h Thu Jun 12 09:29:09 2014
@@ -28,3 +28,10 @@ SV *modperl_module_config_get_obj(pTHX_ 
                                   ap_conf_vector_t *v);
 
 #endif /* MODPERL_MODULE_H */
+
+/*
+ * Local Variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ */

Modified: perl/modperl/trunk/src/modules/perl/modperl_options.c
URL: http://svn.apache.org/viewvc/perl/modperl/trunk/src/modules/perl/modperl_options.c?rev=1602105&r1=1602104&r2=1602105&view=diff
==============================================================================
--- perl/modperl/trunk/src/modules/perl/modperl_options.c (original)
+++ perl/modperl/trunk/src/modules/perl/modperl_options.c Thu Jun 12 09:29:09 2014
@@ -148,3 +148,10 @@ modperl_options_t *modperl_options_merge
 
     return conf;
 }
+
+/*
+ * Local Variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ */

Modified: perl/modperl/trunk/src/modules/perl/modperl_options.h
URL: http://svn.apache.org/viewvc/perl/modperl/trunk/src/modules/perl/modperl_options.h?rev=1602105&r1=1602104&r2=1602105&view=diff
==============================================================================
--- perl/modperl/trunk/src/modules/perl/modperl_options.h (original)
+++ perl/modperl/trunk/src/modules/perl/modperl_options.h Thu Jun 12 09:29:09 2014
@@ -27,3 +27,10 @@ modperl_options_t *modperl_options_merge
                                          modperl_options_t *new);
 
 #endif /* MODPERL_OPTIONS_H */
+
+/*
+ * Local Variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ */

Modified: perl/modperl/trunk/src/modules/perl/modperl_pcw.c
URL: http://svn.apache.org/viewvc/perl/modperl/trunk/src/modules/perl/modperl_pcw.c?rev=1602105&r1=1602104&r2=1602105&view=diff
==============================================================================
--- perl/modperl/trunk/src/modules/perl/modperl_pcw.c (original)
+++ perl/modperl/trunk/src/modules/perl/modperl_pcw.c Thu Jun 12 09:29:09 2014
@@ -140,3 +140,10 @@ void ap_pcw_walk_config(apr_pool_t *pcon
         }
     }
 }
+
+/*
+ * Local Variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ */

Modified: perl/modperl/trunk/src/modules/perl/modperl_pcw.h
URL: http://svn.apache.org/viewvc/perl/modperl/trunk/src/modules/perl/modperl_pcw.h?rev=1602105&r1=1602104&r2=1602105&view=diff
==============================================================================
--- perl/modperl/trunk/src/modules/perl/modperl_pcw.h (original)
+++ perl/modperl/trunk/src/modules/perl/modperl_pcw.h Thu Jun 12 09:29:09 2014
@@ -51,3 +51,10 @@ void ap_pcw_walk_config(apr_pool_t *pcon
                         ap_pcw_dir_cb_t dir_cb, ap_pcw_srv_cb_t srv_cb);
 
 #endif /* MODPERL_PCW_H */
+
+/*
+ * Local Variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ */

Modified: perl/modperl/trunk/src/modules/perl/modperl_perl.c
URL: http://svn.apache.org/viewvc/perl/modperl/trunk/src/modules/perl/modperl_perl.c?rev=1602105&r1=1602104&r2=1602105&view=diff
==============================================================================
--- perl/modperl/trunk/src/modules/perl/modperl_perl.c (original)
+++ perl/modperl/trunk/src/modules/perl/modperl_perl.c Thu Jun 12 09:29:09 2014
@@ -280,3 +280,10 @@ void modperl_hash_seed_set(pTHX)
     }
 #endif
 }
+
+/*
+ * Local Variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ */

Modified: perl/modperl/trunk/src/modules/perl/modperl_perl.h
URL: http://svn.apache.org/viewvc/perl/modperl/trunk/src/modules/perl/modperl_perl.h?rev=1602105&r1=1602104&r2=1602105&view=diff
==============================================================================
--- perl/modperl/trunk/src/modules/perl/modperl_perl.h (original)
+++ perl/modperl/trunk/src/modules/perl/modperl_perl.h Thu Jun 12 09:29:09 2014
@@ -62,3 +62,10 @@ void modperl_hash_seed_set(pTHX);
 #endif
 
 #endif /* MODPERL_PERL_H */
+
+/*
+ * Local Variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ */

Modified: perl/modperl/trunk/src/modules/perl/modperl_perl_global.c
URL: http://svn.apache.org/viewvc/perl/modperl/trunk/src/modules/perl/modperl_perl_global.c?rev=1602105&r1=1602104&r2=1602105&view=diff
==============================================================================
--- perl/modperl/trunk/src/modules/perl/modperl_perl_global.c (original)
+++ perl/modperl/trunk/src/modules/perl/modperl_perl_global.c Thu Jun 12 09:29:09 2014
@@ -494,3 +494,10 @@ void modperl_perl_global_request_restore
                                 MP_perl_global_entries);
 
 }
+
+/*
+ * Local Variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ */

Modified: perl/modperl/trunk/src/modules/perl/modperl_perl_global.h
URL: http://svn.apache.org/viewvc/perl/modperl/trunk/src/modules/perl/modperl_perl_global.h?rev=1602105&r1=1602104&r2=1602105&view=diff
==============================================================================
--- perl/modperl/trunk/src/modules/perl/modperl_perl_global.h (original)
+++ perl/modperl/trunk/src/modules/perl/modperl_perl_global.h Thu Jun 12 09:29:09 2014
@@ -89,3 +89,10 @@ void modperl_perl_global_avcv_clear(pTHX
                                     const char *package, I32 packlen);
 
 #endif
+
+/*
+ * Local Variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ */

Modified: perl/modperl/trunk/src/modules/perl/modperl_perl_includes.h
URL: http://svn.apache.org/viewvc/perl/modperl/trunk/src/modules/perl/modperl_perl_includes.h?rev=1602105&r1=1602104&r2=1602105&view=diff
==============================================================================
--- perl/modperl/trunk/src/modules/perl/modperl_perl_includes.h (original)
+++ perl/modperl/trunk/src/modules/perl/modperl_perl_includes.h Thu Jun 12 09:29:09 2014
@@ -139,3 +139,10 @@
 #endif
 
 #endif /* MODPERL_PERL_INCLUDES_H */
+
+/*
+ * Local Variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ */

Modified: perl/modperl/trunk/src/modules/perl/modperl_perl_pp.c
URL: http://svn.apache.org/viewvc/perl/modperl/trunk/src/modules/perl/modperl_perl_pp.c?rev=1602105&r1=1602104&r2=1602105&view=diff
==============================================================================
--- perl/modperl/trunk/src/modules/perl/modperl_perl_pp.c (original)
+++ perl/modperl/trunk/src/modules/perl/modperl_perl_pp.c Thu Jun 12 09:29:09 2014
@@ -113,3 +113,10 @@ void modperl_perl_pp_unset_all(void)
         modperl_perl_pp_unset(i);
     }
 }
+
+/*
+ * Local Variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ */

Modified: perl/modperl/trunk/src/modules/perl/modperl_perl_pp.h
URL: http://svn.apache.org/viewvc/perl/modperl/trunk/src/modules/perl/modperl_perl_pp.h?rev=1602105&r1=1602104&r2=1602105&view=diff
==============================================================================
--- perl/modperl/trunk/src/modules/perl/modperl_perl_pp.h (original)
+++ perl/modperl/trunk/src/modules/perl/modperl_perl_pp.h Thu Jun 12 09:29:09 2014
@@ -41,3 +41,10 @@ void modperl_perl_pp_unset(modperl_perl_
 void modperl_perl_pp_unset_all(void);
 
 #endif /* MODPERL_PERL_PP_H */
+
+/*
+ * Local Variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ */

Modified: perl/modperl/trunk/src/modules/perl/modperl_perl_unembed.h
URL: http://svn.apache.org/viewvc/perl/modperl/trunk/src/modules/perl/modperl_perl_unembed.h?rev=1602105&r1=1602104&r2=1602105&view=diff
==============================================================================
--- perl/modperl/trunk/src/modules/perl/modperl_perl_unembed.h (original)
+++ perl/modperl/trunk/src/modules/perl/modperl_perl_unembed.h Thu Jun 12 09:29:09 2014
@@ -43,3 +43,10 @@
 #undef list
 
 #endif /* MODPERL_PERL_UNEMBED_H */
+
+/*
+ * Local Variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ */

Modified: perl/modperl/trunk/src/modules/perl/modperl_svptr_table.c
URL: http://svn.apache.org/viewvc/perl/modperl/trunk/src/modules/perl/modperl_svptr_table.c?rev=1602105&r1=1602104&r2=1602105&view=diff
==============================================================================
--- perl/modperl/trunk/src/modules/perl/modperl_svptr_table.c (original)
+++ perl/modperl/trunk/src/modules/perl/modperl_svptr_table.c Thu Jun 12 09:29:09 2014
@@ -184,7 +184,7 @@ modperl_svptr_table_fetch(pTHX_ PTR_TBL_
 {
     PTR_TBL_ENT_t *tblent;
     UV hash = PTR2UV(sv);
-    assert(tbl);
+    MP_ASSERT(tbl);
     tblent = tbl->tbl_ary[hash & tbl->tbl_max];
     for (; tblent; tblent = tblent->next) {
         if (tblent->oldval == sv)
@@ -205,7 +205,7 @@ modperl_svptr_table_store(pTHX_ PTR_TBL_
     UV hash = PTR2UV(oldv);
     bool i = 1;
 
-    assert(tbl);
+    MP_ASSERT(tbl);
     otblent = &tbl->tbl_ary[hash & tbl->tbl_max];
     for (tblent = *otblent; tblent; i=0, tblent = tblent->next) {
         if (tblent->oldval == oldv) {
@@ -303,3 +303,10 @@ modperl_svptr_table_free(pTHX_ PTR_TBL_t
     Safefree(tbl->tbl_ary);
     Safefree(tbl);
 }
+
+/*
+ * Local Variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ */

Modified: perl/modperl/trunk/src/modules/perl/modperl_svptr_table.h
URL: http://svn.apache.org/viewvc/perl/modperl/trunk/src/modules/perl/modperl_svptr_table.h?rev=1602105&r1=1602104&r2=1602105&view=diff
==============================================================================
--- perl/modperl/trunk/src/modules/perl/modperl_svptr_table.h (original)
+++ perl/modperl/trunk/src/modules/perl/modperl_svptr_table.h Thu Jun 12 09:29:09 2014
@@ -55,3 +55,10 @@ void
 modperl_svptr_table_free(pTHX_ PTR_TBL_t *tbl);
 
 #endif /* MODPERL_SVPTR_TABLE_H */
+
+/*
+ * Local Variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ */

Modified: perl/modperl/trunk/src/modules/perl/modperl_sys.c
URL: http://svn.apache.org/viewvc/perl/modperl/trunk/src/modules/perl/modperl_sys.c?rev=1602105&r1=1602104&r2=1602105&view=diff
==============================================================================
--- perl/modperl/trunk/src/modules/perl/modperl_sys.c (original)
+++ perl/modperl/trunk/src/modules/perl/modperl_sys.c Thu Jun 12 09:29:09 2014
@@ -67,3 +67,10 @@ int modperl_sys_dlclose(void *handle)
     return 0;
 #endif
 }
+
+/*
+ * Local Variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ */

Modified: perl/modperl/trunk/src/modules/perl/modperl_sys.h
URL: http://svn.apache.org/viewvc/perl/modperl/trunk/src/modules/perl/modperl_sys.h?rev=1602105&r1=1602104&r2=1602105&view=diff
==============================================================================
--- perl/modperl/trunk/src/modules/perl/modperl_sys.h (original)
+++ perl/modperl/trunk/src/modules/perl/modperl_sys.h Thu Jun 12 09:29:09 2014
@@ -28,3 +28,10 @@ int modperl_sys_is_dir(pTHX_ SV *sv);
 int modperl_sys_dlclose(void *handle);
 
 #endif /* MODPERL_SYS_H */
+
+/*
+ * Local Variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ */

Modified: perl/modperl/trunk/src/modules/perl/modperl_time.h
URL: http://svn.apache.org/viewvc/perl/modperl/trunk/src/modules/perl/modperl_time.h?rev=1602105&r1=1602104&r2=1602105&view=diff
==============================================================================
--- perl/modperl/trunk/src/modules/perl/modperl_time.h (original)
+++ perl/modperl/trunk/src/modules/perl/modperl_time.h Thu Jun 12 09:29:09 2014
@@ -50,3 +50,10 @@
     })
 
 #endif /* MODPERL_TIME_H */
+
+/*
+ * Local Variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ */

Modified: perl/modperl/trunk/src/modules/perl/modperl_tipool.c
URL: http://svn.apache.org/viewvc/perl/modperl/trunk/src/modules/perl/modperl_tipool.c?rev=1602105&r1=1602104&r2=1602105&view=diff
==============================================================================
--- perl/modperl/trunk/src/modules/perl/modperl_tipool.c (original)
+++ perl/modperl/trunk/src/modules/perl/modperl_tipool.c Thu Jun 12 09:29:09 2014
@@ -401,3 +401,10 @@ void modperl_tipool_putback(modperl_tipo
 }
 
 #endif /* USE_ITHREADS */
+
+/*
+ * Local Variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ */

Modified: perl/modperl/trunk/src/modules/perl/modperl_tipool.h
URL: http://svn.apache.org/viewvc/perl/modperl/trunk/src/modules/perl/modperl_tipool.h?rev=1602105&r1=1602104&r2=1602105&view=diff
==============================================================================
--- perl/modperl/trunk/src/modules/perl/modperl_tipool.h (original)
+++ perl/modperl/trunk/src/modules/perl/modperl_tipool.h Thu Jun 12 09:29:09 2014
@@ -87,3 +87,10 @@ void modperl_tipool_putback_data(modperl
 #endif /* USE_ITHREADS */
 
 #endif /* MODPERL_TIPOOL_H */
+
+/*
+ * Local Variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ */

Modified: perl/modperl/trunk/src/modules/perl/modperl_types.h
URL: http://svn.apache.org/viewvc/perl/modperl/trunk/src/modules/perl/modperl_types.h?rev=1602105&r1=1602104&r2=1602105&view=diff
==============================================================================
--- perl/modperl/trunk/src/modules/perl/modperl_types.h (original)
+++ perl/modperl/trunk/src/modules/perl/modperl_types.h Thu Jun 12 09:29:09 2014
@@ -40,6 +40,8 @@ typedef struct {
     server_rec  *s;
 } modperl_rcs_t;
 
+typedef struct modperl_config_con_t modperl_config_con_t;
+
 #ifdef USE_ITHREADS
 
 typedef struct modperl_list_t modperl_list_t;
@@ -52,13 +54,14 @@ struct modperl_list_t {
 typedef struct modperl_interp_t modperl_interp_t;
 typedef struct modperl_interp_pool_t modperl_interp_pool_t;
 typedef struct modperl_tipool_t modperl_tipool_t;
+typedef struct modperl_tipool_config_t modperl_tipool_config_t;
 
 struct modperl_interp_t {
     modperl_interp_pool_t *mip;
     PerlInterpreter *perl;
     int num_requests;
     U8 flags;
-    request_rec *request;
+    modperl_config_con_t *ccfg;
     int refcnt;
 #ifdef MP_TRACE
     unsigned long tid;
@@ -79,13 +82,13 @@ typedef struct {
                         modperl_list_t *listp);
 } modperl_tipool_vtbl_t;
 
-typedef struct {
+struct modperl_tipool_config_t {
     int start; /* number of items to create at startup */
     int min_spare; /* minimum number of spare items */
     int max_spare; /* maximum number of spare items */
     int max; /* maximum number of items */
     int max_requests; /* maximum number of requests per item */
-} modperl_tipool_config_t;
+};
 
 struct modperl_tipool_t {
     perl_mutex tiplock;
@@ -240,11 +243,21 @@ typedef struct {
     int sent_eos;
     SV *data;
     modperl_handler_t *handler;
-    PerlInterpreter *perl;
+#ifdef USE_ITHREADS
+    modperl_interp_t *interp;
+#endif
 } modperl_filter_ctx_t;
 
 typedef struct {
     HV *pnotes;
+    apr_pool_t *pool;
+#ifdef USE_ITHREADS
+    modperl_interp_t *interp;
+#endif
+} modperl_pnotes_t;
+
+typedef struct {
+    modperl_pnotes_t pnotes;
     SV *global_request_obj;
     U8 flags;
     int status;
@@ -252,14 +265,14 @@ typedef struct {
     MpAV *handlers_per_dir[MP_HANDLER_NUM_PER_DIR];
     MpAV *handlers_per_srv[MP_HANDLER_NUM_PER_SRV];
     modperl_perl_globals_t perl_globals;
+} modperl_config_req_t;
+
+struct modperl_config_con_t {
+    modperl_pnotes_t pnotes;
 #ifdef USE_ITHREADS
     modperl_interp_t *interp;
 #endif
-} modperl_config_req_t;
-
-typedef struct {
-    HV *pnotes;
-} modperl_config_con_t;
+};
 
 typedef struct {
     apr_pool_t *pool;
@@ -279,3 +292,10 @@ typedef enum {
 } modperl_hook_run_mode_e;
 
 #endif /* MODPERL_TYPES_H */
+
+/*
+ * Local Variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ */



Mime
View raw message