perl-modperl-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From steve...@apache.org
Subject svn commit: r1537772 - in /perl/modperl/branches/httpd24threading: ./ src/modules/perl/
Date Fri, 01 Nov 2013 00:03:17 GMT
Author: stevehay
Date: Fri Nov  1 00:03:16 2013
New Revision: 1537772

URL: http://svn.apache.org/r1537772
Log:
Merged revision(s) 1075807, 1241583, 1241983-1241984, 1241987, 1242010, 1242050, 1242068 from
perl/modperl/branches/threading:
reintroduce MP_dTHX macro
........
modperl_interp_pool_select() when used to create or merge dir-configs
at runtime may pull the interpreter from the wrong pool if the request's
server is a vhost with a separate interpreter pool.

........
improve MP_TRACE output a bit: include current perl context for
threaded perls

........
rename assert() => ap_assert()
........
similar to r1241583: make sure r->server is used to identify the interpreter
pool to pull from at runtime.

........
comment added
........
remove a bit of code complexity

modperl_module.c contains these 2 lines:

	interp = modperl_interp_pool_select(p, s);
	MP_PERL_CONTEXT_STORE_OVERRIDE(interp->perl);

The latter decodes as

	orig_perl = PERL_GET_CONTEXT;
	aTHX = interp->perl;
	PERL_SET_CONTEXT(aTHX);

Now, modperl_interp_pool_select() already calls PERL_SET_CONTEXT with the
newly allocated interpreter. So, we get

	PERL_SET_CONTEXT(interp->perl);
	orig_perl = PERL_GET_CONTEXT;
	aTHX = interp->perl;
	PERL_SET_CONTEXT(aTHX);

But this is the same as

	interp = modperl_interp_pool_select(p, s);
	aTHX = interp->perl;

........
ap_assert => MP_ASSERT (depends on MP_DEBUG)
........

Modified:
    perl/modperl/branches/httpd24threading/   (props changed)
    perl/modperl/branches/httpd24threading/Changes
    perl/modperl/branches/httpd24threading/src/modules/perl/mod_perl.c
    perl/modperl/branches/httpd24threading/src/modules/perl/modperl_common_log.c
    perl/modperl/branches/httpd24threading/src/modules/perl/modperl_config.h
    perl/modperl/branches/httpd24threading/src/modules/perl/modperl_debug.h
    perl/modperl/branches/httpd24threading/src/modules/perl/modperl_interp.c
    perl/modperl/branches/httpd24threading/src/modules/perl/modperl_module.c
    perl/modperl/branches/httpd24threading/src/modules/perl/modperl_svptr_table.c

Propchange: perl/modperl/branches/httpd24threading/
------------------------------------------------------------------------------
  Merged /perl/modperl/branches/threading:r1075807,1241583,1241983-1241984,1241987,1242010,1242050,1242068

Modified: perl/modperl/branches/httpd24threading/Changes
URL: http://svn.apache.org/viewvc/perl/modperl/branches/httpd24threading/Changes?rev=1537772&r1=1537771&r2=1537772&view=diff
==============================================================================
--- perl/modperl/branches/httpd24threading/Changes (original)
+++ perl/modperl/branches/httpd24threading/Changes Fri Nov  1 00:03:16 2013
@@ -12,6 +12,12 @@ Also refer to the Apache::Test changes l
 
 =item 2.0.9-dev
 
+Make sure modperl_interp_select uses r->server rather than the passed s
+parameter to find the interpreter pool to pull an interpreter from. This
+fixes an issue with vhosts with a separate interpreter pool and runtime
+dir-config merges that used to pull the interpreter from the wrong pool.
+[Torsten Foertsch]
+
 PerlInterpScope is now more advisory. Using $(c|r)->pnotes will bind
 the current interpreter to that object for it's lifetime.
 $(c|r)->pnotes_kill() can be used to prematurely drop pnotes and

Modified: perl/modperl/branches/httpd24threading/src/modules/perl/mod_perl.c
URL: http://svn.apache.org/viewvc/perl/modperl/branches/httpd24threading/src/modules/perl/mod_perl.c?rev=1537772&r1=1537771&r2=1537772&view=diff
==============================================================================
--- perl/modperl/branches/httpd24threading/src/modules/perl/mod_perl.c (original)
+++ perl/modperl/branches/httpd24threading/src/modules/perl/mod_perl.c Fri Nov  1 00:03:16
2013
@@ -742,11 +742,17 @@ static int modperl_hook_create_request(r
     MP_dRCFG;
 
 #ifdef USE_ITHREADS
-    if (modperl_threaded_mpm()) {
-        MP_TRACE_i(MP_FUNC, "setting userdata MODPERL_R in pool %#lx to %lx",
-                   (unsigned long)r->pool, (unsigned long)r);
-      (void)apr_pool_userdata_set((void *)r, "MODPERL_R", NULL, r->pool);
-    }
+    /* XXX: this is necessary to make modperl_interp_pool_select() work
+     * which is used at runtime only to merge dir-configs by
+     * modperl_module_config_merge().
+     *
+     * Since most requests won't need it it would be good to add some logic
+     * (cheaper logic in terms of CPU cycles) to identify those cases and
+     * avoid the hash operation.
+     */
+    MP_TRACE_i(MP_FUNC, "setting userdata MODPERL_R in pool %#lx to %lx",
+               (unsigned long)r->pool, (unsigned long)r);
+    (void)apr_pool_userdata_set((void *)r, "MODPERL_R", NULL, r->pool);
 #endif
 
     modperl_config_req_init(r, rcfg);

Modified: perl/modperl/branches/httpd24threading/src/modules/perl/modperl_common_log.c
URL: http://svn.apache.org/viewvc/perl/modperl/branches/httpd24threading/src/modules/perl/modperl_common_log.c?rev=1537772&r1=1537771&r2=1537772&view=diff
==============================================================================
--- perl/modperl/branches/httpd24threading/src/modules/perl/modperl_common_log.c (original)
+++ perl/modperl/branches/httpd24threading/src/modules/perl/modperl_common_log.c Fri Nov 
1 00:03:16 2013
@@ -49,14 +49,27 @@ void modperl_trace(const char *func, con
         return;
     }
 
+    /* for more information on formatting codes see
+       http://apr.apache.org/docs/apr/1.4/group__apr__lib.html#gad2cd3594aeaafd45931d1034965f48c1
+     */
     if (modperl_threaded_mpm()) {
-        apr_file_printf(logfile, "[%lu/%lu] ", (unsigned long)getpid(),
-                        modperl_threads_started()
-                        ? (unsigned long)apr_os_thread_current()
-                        : 0);
+        if (modperl_threads_started()) {
+            apr_file_printf(logfile, "[pid=%lu, tid=%pt, perl=%pp] ",
+                            (unsigned long)getpid(),
+                            (void*)apr_os_thread_current(), PERL_GET_CONTEXT);
+        }
+        else {
+            apr_file_printf(logfile, "[pid=%lu, perl=%pp] ",
+                            (unsigned long)getpid(), PERL_GET_CONTEXT);
+        }
     }
     else {
-        apr_file_printf(logfile, "[%lu] ", (unsigned long)getpid());
+#ifdef USE_ITHREADS
+        apr_file_printf(logfile, "[pid=%lu, perl=%pp] ",
+                        (unsigned long)getpid(), PERL_GET_CONTEXT);
+#else
+        apr_file_printf(logfile, "[pid=%lu] ", (unsigned long)getpid());
+#endif
     }
 
     if (func && *func) {

Modified: perl/modperl/branches/httpd24threading/src/modules/perl/modperl_config.h
URL: http://svn.apache.org/viewvc/perl/modperl/branches/httpd24threading/src/modules/perl/modperl_config.h?rev=1537772&r1=1537771&r2=1537772&view=diff
==============================================================================
--- perl/modperl/branches/httpd24threading/src/modules/perl/modperl_config.h (original)
+++ perl/modperl/branches/httpd24threading/src/modules/perl/modperl_config.h Fri Nov  1 00:03:16
2013
@@ -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);                      \
@@ -64,25 +64,25 @@ void modperl_set_perl_module_config(ap_c
 #   define modperl_get_module_config(v)         \
     modperl_get_perl_module_config(v)
 
-#   define modperl_set_module_config(v, c)      \
-    modperl_set_perl_module_config(v, c)
+#   define modperl_set_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)
@@ -132,8 +132,10 @@ void modperl_set_perl_module_config(ap_c
     modperl_interp_t *interp =                                  \
         modperl_interp_select(r, r->connection, r->server);     \
     dTHXa(interp->perl)
+#   define MP_uTHX modperl_interp_unselect(interp)
 #else
 #   define MP_dTHX dNOOP
+#   define MP_uTHX dNOOP
 #endif
 
 int modperl_config_apply_PerlModule(server_rec *s,

Modified: perl/modperl/branches/httpd24threading/src/modules/perl/modperl_debug.h
URL: http://svn.apache.org/viewvc/perl/modperl/branches/httpd24threading/src/modules/perl/modperl_debug.h?rev=1537772&r1=1537771&r2=1537772&view=diff
==============================================================================
--- perl/modperl/branches/httpd24threading/src/modules/perl/modperl_debug.h (original)
+++ perl/modperl/branches/httpd24threading/src/modules/perl/modperl_debug.h Fri Nov  1 00:03:16
2013
@@ -19,6 +19,12 @@
 
 #include "mod_perl.h"
 
+#ifdef MP_DEBUG
+#define MP_ASSERT(exp) ap_assert(exp)
+#else
+#define MP_ASSERT(exp) ((void)0)
+#endif
+
 char *modperl_server_desc(server_rec *s, apr_pool_t *p);
 
 #ifdef MP_TRACE

Modified: perl/modperl/branches/httpd24threading/src/modules/perl/modperl_interp.c
URL: http://svn.apache.org/viewvc/perl/modperl/branches/httpd24threading/src/modules/perl/modperl_interp.c?rev=1537772&r1=1537771&r2=1537772&view=diff
==============================================================================
--- perl/modperl/branches/httpd24threading/src/modules/perl/modperl_interp.c (original)
+++ perl/modperl/branches/httpd24threading/src/modules/perl/modperl_interp.c Fri Nov  1 00:03:16
2013
@@ -285,7 +285,7 @@ apr_status_t modperl_interp_unselect(voi
 
     if (interp == mip->parent) return APR_SUCCESS;
 
-    ap_assert(interp && MpInterpIN_USE(interp));
+    MP_ASSERT(interp && MpInterpIN_USE(interp));
     MP_TRACE_i(MP_FUNC, "unselect(interp=0x%lx): refcnt=%d",
                (unsigned long)interp, interp->refcnt);
     if (interp->refcnt != 0) {
@@ -345,10 +345,10 @@ 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 (is_startup) {
+        MP_dSCFG(s);
         if (scfg) {
             MP_TRACE_i(MP_FUNC, "using parent interpreter at startup");
 
@@ -389,31 +389,20 @@ modperl_interp_t *modperl_interp_pool_se
 
         return interp;
     }
-    else if (!modperl_threaded_mpm()) {
-        MP_TRACE_i(MP_FUNC, "using parent interpreter in non-threaded mode");
-
-        /* since we are not running in threaded mode PERL_SET_CONTEXT
-         * is not necessary */
-        /* PERL_SET_CONTEXT(scfg->mip->parent->perl); */
-        /* let the perl interpreter point back to its interp */
-        MP_THX_INTERP_SET(scfg->mip->parent->perl, scfg->mip->parent);
-
-        return scfg->mip->parent;
-    }
     else {
         request_rec *r;
         apr_pool_userdata_get((void **)&r, "MODPERL_R", p);
-        ap_assert(r);
+        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, s);
+        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_dSCFG((r ? s=r->server : s ? s : NULL));
     MP_dDCFG;
     modperl_config_con_t *ccfg;
     const char *desc = NULL;
@@ -450,7 +439,10 @@ modperl_interp_t *modperl_interp_select(
         return ccfg->interp;
     }
 
-    interp = modperl_interp_get(s ? s : r->server);
+    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", interp);
     ++interp->num_requests; /* should only get here once per request */
     interp->refcnt = 0;
 
@@ -505,7 +497,7 @@ modperl_interp_t *modperl_interp_select(
             }
 	}
 
-        ap_assert(p);
+        MP_ASSERT(p);
 
 #ifdef MP_TRACE
         apr_pool_cleanup_register(p, (void *)interp,

Modified: perl/modperl/branches/httpd24threading/src/modules/perl/modperl_module.c
URL: http://svn.apache.org/viewvc/perl/modperl/branches/httpd24threading/src/modules/perl/modperl_module.c?rev=1537772&r1=1537771&r2=1537772&view=diff
==============================================================================
--- perl/modperl/branches/httpd24threading/src/modules/perl/modperl_module.c (original)
+++ perl/modperl/branches/httpd24threading/src/modules/perl/modperl_module.c Fri Nov  1 00:03:16
2013
@@ -168,7 +168,7 @@ static void *modperl_module_config_merge
     SV *mrg_obj = (SV *)NULL, *base_obj, *add_obj;
 #ifdef USE_ITHREADS
     modperl_interp_t *interp;
-    MP_PERL_CONTEXT_DECLARE;
+    pTHX;
 #endif
 
     /* if the module is loaded in vhost, base==NULL */
@@ -184,7 +184,7 @@ static void *modperl_module_config_merge
 
 #ifdef USE_ITHREADS
     interp = modperl_interp_pool_select(p, s);
-    MP_PERL_CONTEXT_STORE_OVERRIDE(interp->perl);
+    aTHX = interp->perl;
 #endif
 
     table = modperl_module_config_table_get(aTHX_ TRUE);
@@ -196,7 +196,6 @@ static void *modperl_module_config_merge
         MP_TRACE_i(MP_FUNC, "unselecting: (0x%lx)->refcnt=%ld",
                    interp, interp->refcnt);
         modperl_interp_unselect(interp);
-        MP_PERL_CONTEXT_RESTORE;
 #endif
         return addv;
     }
@@ -250,7 +249,6 @@ static void *modperl_module_config_merge
     MP_TRACE_i(MP_FUNC, "unselecting: (0x%lx)->refcnt=%ld",
                interp, interp->refcnt);
     modperl_interp_unselect(interp);
-    MP_PERL_CONTEXT_RESTORE;
 #endif
 
     return (void *)mrg;

Modified: perl/modperl/branches/httpd24threading/src/modules/perl/modperl_svptr_table.c
URL: http://svn.apache.org/viewvc/perl/modperl/branches/httpd24threading/src/modules/perl/modperl_svptr_table.c?rev=1537772&r1=1537771&r2=1537772&view=diff
==============================================================================
--- perl/modperl/branches/httpd24threading/src/modules/perl/modperl_svptr_table.c (original)
+++ perl/modperl/branches/httpd24threading/src/modules/perl/modperl_svptr_table.c Fri Nov
 1 00:03:16 2013
@@ -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) {



Mime
View raw message