Skip to content

Commit 00b8c28

Browse files
author
Jan Kaluža
committed
Remove PerlInterpScope directive as discussed on mailing list. PerlInterpScope
did not work correctly with httpd-2.4.x threaded MPMs. For example when using 'PerlInterpScope connection' and multiple requests are handled using the single connection, every request tries to fetch new interpreter. This leads to deadlock soon, because we can always have more requests than interpreters. There are more situations like the one described above and the fix is quite hard with the way how the usage of PerlInterpeters is designed currently. git-svn-id: https://svn.apache.org/repos/asf/perl/modperl/trunk@1682369 13f79535-47bb-0310-9956-ffa450edef68
1 parent 7a63115 commit 00b8c28

File tree

12 files changed

+8
-182
lines changed

12 files changed

+8
-182
lines changed

Changes

+3
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ Also refer to the Apache::Test changes log file, at Apache-Test/Changes
1010

1111
=over 3
1212

13+
Remove PerlInterpScope. This has not been working properly with threaded
14+
MPMs with httpd-2.4.x and the use-case of this directive was questionable.
15+
1316
=item 2.0.9-rc1
1417

1518
Add support for Apache httpd-2.4.x. [Torsten Foertsch, Jan Kaluza,

src/modules/perl/mod_perl.c

-5
Original file line numberDiff line numberDiff line change
@@ -503,9 +503,6 @@ static void modperl_init_clones(server_rec *s, apr_pool_t *p)
503503
MP_dSCFG(s);
504504
#ifdef MP_TRACE
505505
char *name = modperl_server_desc(s, p);
506-
507-
MP_TRACE_i(MP_FUNC, "PerlInterpScope set to %s for %s",
508-
modperl_interp_scope_desc(scfg->interp_scope), name);
509506
#else
510507
char *name = NULL;
511508
#endif /* MP_TRACE */
@@ -973,8 +970,6 @@ static const command_rec modperl_cmds[] = {
973970
"Min number of spare Perl interpreters"),
974971
MP_CMD_SRV_TAKE1("PerlInterpMaxRequests", interp_max_requests,
975972
"Max number of requests per Perl interpreters"),
976-
MP_CMD_DIR_TAKE1("PerlInterpScope", interp_scope,
977-
"Scope of a Perl interpreter"),
978973
#endif
979974
#ifdef MP_COMPAT_1X
980975
MP_CMD_DIR_FLAG("PerlSendHeader", send_header,

src/modules/perl/modperl_bucket.c

-1
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,6 @@ static apr_bucket *modperl_bucket_sv_make(pTHX_
121121
return NULL;
122122
}
123123

124-
/* XXX: need to deal with PerlInterpScope */
125124
#ifdef USE_ITHREADS
126125
svbucket->perl = aTHX;
127126
#endif

src/modules/perl/modperl_cmd.c

-52
Original file line numberDiff line numberDiff line change
@@ -795,58 +795,6 @@ MP_CMD_SRV_DECLARE_FLAG(setup_env)
795795

796796
#ifdef USE_ITHREADS
797797

798-
#define MP_INTERP_SCOPE_USAGE "PerlInterpScope must be one of "
799-
800-
#define MP_INTERP_SCOPE_DIR_OPTS \
801-
"handler, subrequest or request"
802-
803-
#define MP_INTERP_SCOPE_DIR_USAGE \
804-
MP_INTERP_SCOPE_USAGE MP_INTERP_SCOPE_DIR_OPTS
805-
806-
#define MP_INTERP_SCOPE_SRV_OPTS \
807-
"connection, " MP_INTERP_SCOPE_DIR_OPTS
808-
809-
#define MP_INTERP_SCOPE_SRV_USAGE \
810-
MP_INTERP_SCOPE_USAGE MP_INTERP_SCOPE_SRV_OPTS
811-
812-
MP_CMD_SRV_DECLARE(interp_scope)
813-
{
814-
modperl_interp_scope_e *scope;
815-
modperl_config_dir_t *dcfg = (modperl_config_dir_t *)mconfig;
816-
MP_dSCFG(parms->server);
817-
int is_per_dir = parms->path ? 1 : 0;
818-
819-
scope = is_per_dir ? &dcfg->interp_scope : &scfg->interp_scope;
820-
821-
switch (toLOWER(*arg)) {
822-
case 'h':
823-
if (strcaseEQ(arg, "handler")) {
824-
*scope = MP_INTERP_SCOPE_HANDLER;
825-
break;
826-
}
827-
case 's':
828-
if (strcaseEQ(arg, "subrequest")) {
829-
*scope = MP_INTERP_SCOPE_SUBREQUEST;
830-
break;
831-
}
832-
case 'r':
833-
if (strcaseEQ(arg, "request")) {
834-
*scope = MP_INTERP_SCOPE_REQUEST;
835-
break;
836-
}
837-
case 'c':
838-
if (!is_per_dir && strcaseEQ(arg, "connection")) {
839-
*scope = MP_INTERP_SCOPE_CONNECTION;
840-
break;
841-
}
842-
default:
843-
return is_per_dir ?
844-
MP_INTERP_SCOPE_DIR_USAGE : MP_INTERP_SCOPE_SRV_USAGE;
845-
};
846-
847-
return NULL;
848-
}
849-
850798
#define MP_CMD_INTERP_POOL_IMP(xitem) \
851799
const char *modperl_cmd_interp_##xitem(cmd_parms *parms, \
852800
void *mconfig, const char *arg) \

src/modules/perl/modperl_cmd.h

-16
Original file line numberDiff line numberDiff line change
@@ -77,22 +77,6 @@ MP_CMD_SRV_DECLARE(interp_max);
7777
MP_CMD_SRV_DECLARE(interp_max_spare);
7878
MP_CMD_SRV_DECLARE(interp_min_spare);
7979
MP_CMD_SRV_DECLARE(interp_max_requests);
80-
MP_CMD_SRV_DECLARE(interp_scope);
81-
82-
#define modperl_interp_scope_undef(dcfg) \
83-
(dcfg->interp_scope == MP_INTERP_SCOPE_UNDEF)
84-
85-
#define modperl_interp_scope_handler(dcfg) \
86-
(dcfg->interp_scope == MP_INTERP_SCOPE_HANDLER)
87-
88-
#define modperl_interp_scope_subrequest(dcfg) \
89-
(dcfg->interp_scope == MP_INTERP_SCOPE_SUBREQUEST)
90-
91-
#define modperl_interp_scope_request(scfg) \
92-
(scfg->interp_scope == MP_INTERP_SCOPE_REQUEST)
93-
94-
#define modperl_interp_scope_connection(scfg) \
95-
(scfg->interp_scope == MP_INTERP_SCOPE_CONNECTION)
9680

9781
#endif /* USE_ITHREADS */
9882

src/modules/perl/modperl_config.c

-12
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,6 @@ void *modperl_config_dir_create(apr_pool_t *p, char *dir)
2424

2525
MP_TRACE_d(MP_FUNC, "dir %s", dir);
2626

27-
#ifdef USE_ITHREADS
28-
/* defaults to per-server scope */
29-
dcfg->interp_scope = MP_INTERP_SCOPE_UNDEF;
30-
#endif
31-
3227
return dcfg;
3328
}
3429

@@ -114,10 +109,6 @@ void *modperl_config_dir_merge(apr_pool_t *p, void *basev, void *addv)
114109
(unsigned long)basev, (unsigned long)addv,
115110
(unsigned long)mrg);
116111

117-
#ifdef USE_ITHREADS
118-
merge_item(interp_scope);
119-
#endif
120-
121112
mrg->flags = modperl_options_merge(p, base->flags, add->flags);
122113

123114
merge_item(location);
@@ -262,8 +253,6 @@ void *modperl_config_srv_create(apr_pool_t *p, server_rec *s)
262253
(modperl_tipool_config_t *)
263254
apr_pcalloc(p, sizeof(*scfg->interp_pool_cfg));
264255

265-
scfg->interp_scope = MP_INTERP_SCOPE_REQUEST;
266-
267256
/* XXX: determine reasonable defaults */
268257
scfg->interp_pool_cfg->start = 3;
269258
scfg->interp_pool_cfg->max_spare = 3;
@@ -308,7 +297,6 @@ void *modperl_config_srv_merge(apr_pool_t *p, void *basev, void *addv)
308297

309298
#ifdef USE_ITHREADS
310299
merge_item(interp_pool_cfg);
311-
merge_item(interp_scope);
312300
#else
313301
merge_item(perl);
314302
#endif

src/modules/perl/modperl_interp.c

-77
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,6 @@
2323

2424
#ifdef USE_ITHREADS
2525

26-
static const char *MP_interp_scope_desc[] = {
27-
"undef", "handler", "subrequest", "request", "connection",
28-
};
29-
30-
const char *modperl_interp_scope_desc(modperl_interp_scope_e scope)
31-
{
32-
return MP_interp_scope_desc[scope];
33-
}
34-
3526
void modperl_interp_clone_init(modperl_interp_t *interp)
3627
{
3728
dTHXa(interp->perl);
@@ -258,16 +249,6 @@ void modperl_interp_init(server_rec *s, apr_pool_t *p,
258249
scfg->mip = mip;
259250
}
260251

261-
#ifdef MP_TRACE
262-
static apr_status_t modperl_interp_pool_cleanup(void *data)
263-
{
264-
MP_TRACE_i(MP_FUNC, "unselecting: (0x%lx)->refcnt=%ld",
265-
data, ((modperl_interp_t*)data)->refcnt);
266-
267-
return modperl_interp_unselect(data);
268-
}
269-
#endif
270-
271252
apr_status_t modperl_interp_unselect(void *data)
272253
{
273254
modperl_interp_t *interp = (modperl_interp_t *)data;
@@ -413,7 +394,6 @@ modperl_interp_t *modperl_interp_select(request_rec *r, conn_rec *c,
413394
const char *desc = NULL;
414395
modperl_interp_t *interp = NULL;
415396
apr_pool_t *p = NULL;
416-
modperl_interp_scope_e scope;
417397

418398
/* What does the following condition mean?
419399
* (r || c): if true we are at runtime. There is some kind of request
@@ -476,63 +456,6 @@ modperl_interp_t *modperl_interp_select(request_rec *r, conn_rec *c,
476456
"pulled interp %pp (perl=%pp) from mip, num_requests is %d",
477457
interp, interp->perl, interp->num_requests);
478458

479-
/*
480-
* if a per-dir PerlInterpScope is specified, use it.
481-
* else if r != NULL use per-server PerlInterpScope
482-
* else scope must be per-connection
483-
*/
484-
485-
scope = (dcfg && !modperl_interp_scope_undef(dcfg)) ?
486-
dcfg->interp_scope :
487-
(r ? scfg->interp_scope : MP_INTERP_SCOPE_CONNECTION);
488-
489-
MP_TRACE_i(MP_FUNC, "scope is per-%s",
490-
modperl_interp_scope_desc(scope));
491-
492-
if (scope != MP_INTERP_SCOPE_HANDLER) {
493-
desc = NULL;
494-
if (c && (scope == MP_INTERP_SCOPE_CONNECTION || !r)) {
495-
p = c->pool;
496-
desc = "connection";
497-
}
498-
else if (r) {
499-
request_rec *main_r = r->main;
500-
501-
if (main_r && (scope == MP_INTERP_SCOPE_REQUEST)) {
502-
/* share 1 interpreter across sub-requests */
503-
for(; main_r; main_r = main_r->main) {
504-
p = main_r->pool;
505-
}
506-
desc = "main request";
507-
}
508-
else {
509-
p = r->pool;
510-
desc = scope == MP_INTERP_SCOPE_REQUEST
511-
? "main request"
512-
: "sub request";
513-
}
514-
}
515-
516-
MP_ASSERT(p);
517-
518-
#ifdef MP_TRACE
519-
apr_pool_cleanup_register(p, (void *)interp,
520-
modperl_interp_pool_cleanup,
521-
modperl_interp_pool_cleanup);
522-
#else
523-
apr_pool_cleanup_register(p, (void *)interp,
524-
modperl_interp_unselect,
525-
modperl_interp_unselect);
526-
#endif
527-
528-
/* add a reference for the registered cleanup */
529-
interp->refcnt++;
530-
531-
MP_TRACE_i(MP_FUNC,
532-
"registered unselect cleanup for interp 0x%lx in %s",
533-
(unsigned long)interp, desc);
534-
}
535-
536459
return interp;
537460
}
538461

src/modules/perl/modperl_interp.h

-2
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,6 @@ apr_status_t modperl_interp_cleanup(void *data);
2727
modperl_interp_t *modperl_thx_interp_get(PerlInterpreter *thx);
2828
void modperl_thx_interp_set(PerlInterpreter *thx, modperl_interp_t *interp);
2929

30-
const char *modperl_interp_scope_desc(modperl_interp_scope_e scope);
31-
3230
void modperl_interp_clone_init(modperl_interp_t *interp);
3331

3432
modperl_interp_t *modperl_interp_new(modperl_interp_pool_t *mip,

src/modules/perl/modperl_types.h

-12
Original file line numberDiff line numberDiff line change
@@ -120,14 +120,6 @@ typedef struct {
120120
int unset;
121121
} modperl_options_t;
122122

123-
typedef enum {
124-
MP_INTERP_SCOPE_UNDEF,
125-
MP_INTERP_SCOPE_HANDLER,
126-
MP_INTERP_SCOPE_SUBREQUEST,
127-
MP_INTERP_SCOPE_REQUEST,
128-
MP_INTERP_SCOPE_CONNECTION
129-
} modperl_interp_scope_e;
130-
131123
typedef struct {
132124
MpHV *setvars;
133125
MpHV *configvars;
@@ -142,7 +134,6 @@ typedef struct {
142134
#ifdef USE_ITHREADS
143135
modperl_interp_pool_t *mip;
144136
modperl_tipool_config_t *interp_pool_cfg;
145-
modperl_interp_scope_e interp_scope;
146137
#else
147138
PerlInterpreter *perl;
148139
#endif
@@ -163,9 +154,6 @@ typedef struct {
163154
MpHV *setvars;
164155
MpHV *configvars;
165156
modperl_options_t *flags;
166-
#ifdef USE_ITHREADS
167-
modperl_interp_scope_e interp_scope;
168-
#endif
169157
} modperl_config_dir_t;
170158

171159
typedef struct {

t/response/TestDirective/perlcleanuphandler.pm

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ __END__
4444
PerlInterpMax 1
4545
PerlInterpMinSpare 0
4646
PerlInterpMaxSpare 1
47-
PerlInterpScope connection
47+
# PerlInterpScope connection
4848
</IfDefine>
4949
5050
KeepAlive On

t/response/TestModperl/setupenv.pm

+3-3
Original file line numberDiff line numberDiff line change
@@ -182,9 +182,9 @@ __DATA__
182182
183183
KeepAlive On
184184
185-
<IfDefine PERL_USEITHREADS>
186-
PerlInterpScope connection
187-
</Ifdefine>
185+
# <IfDefine PERL_USEITHREADS>
186+
# PerlInterpScope connection
187+
# </Ifdefine>
188188
189189
PerlModule TestModperl::setupenv
190190

t/response/TestPerl/ithreads3.pm

+1-1
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ __END__
8686
PerlInterpMax 3
8787
PerlInterpMinSpare 1
8888
PerlInterpMaxSpare 3
89-
PerlInterpScope handler
89+
# PerlInterpScope handler
9090
</IfDefine>
9191
9292
# use test system's @INC

0 commit comments

Comments
 (0)