mod_perl不能使用线程MPM没有线程启用Perl



首先,我在几年前问过一个类似的问题,关于一个没有线程的旧版本的Compile Perl,但是我以前的答案现在似乎不起作用了。

我的设置是一个自定义编译版本的Perl

This is perl 5, version 34, subversion 1 (v5.34.1) built for x86_64-linux
CFLAGS='-m64 -mtune=nocona' ./Configure -des -A ccflags=-fPIC -Dprefix=/opt/perl

根据我的理解,线程没有启用(我认为如果是这样的话,它会在最后说)

我试着在Apache 2.4.53上运行这个(但我不认为它已经走了那么远)。

Apache配置选项…

./configure --enable-proxy --enable-rewrite --enable-headers --enable-ssl --with-apr=/usr/local/apr/

据我所知,和之前的答案,如果使用Perl没有线程,你可以编译mod_perl没有线程,这是通过使用

mod_perl version is 2.0.12
MP_NO_THREADS=1
所以我编译mod_perl的完整命令是
perl Makefile.PL MP_NO_THREADS=1 MP_APXS=/usr/local/apache2/bin/apxs

自述文件说…

# For httpd-2.4, we can't use mpm_is_threaded(), because MPMs are loadable
# modules. We therefore treat httpd as a whole project as threaded. It is
# still possible to disable threading by using MP_NO_THREADS=1

我还可以在Makefile.PL

中看到一些代码。
if ($build->{MP_NO_THREADS}) {
$build_threaded = 0;
}

,我可以看到$build_thread确实被设置为0。

然而,当我make && make test

[Thu Apr 28 12:18:02.392480 2022] [perl:error] [pid 38185:tid 140616570507840] 
cannot use threaded MPM without ithreads enabled Perl

我真的看不到代码中的任何东西(除了检查),但是根据代码的不同,我做了任何不同的事情,但是我对它一点也不熟悉,所以可能遗漏了一些重要的东西?

I have also tried with -Uuseithreads -Uusethreads -Dusethreads=undef

编辑:产生错误的代码看起来像

## src/modules/perl/mod_perl.c
#ifndef USE_ITHREADS
if (modperl_threaded_mpm()) {
ap_log_error(APLOG_MARK, APLOG_ERR, 0, base_server,
"cannot use threaded MPM without ithreads enabled Perl");
exit(1);
}
#endif
and
Apache2::Build::PERL_HAS_ITHREADS ? "w/" : "w/o";
shows as "w/o" when running

进一步挖掘,我看到代码似乎调用ap_mpm_query(),所以检查与Apache和apachectl -v这看起来不正确…我认为线程应该没有,所以检查为什么这是…

Server MPM:     event
threaded:     yes (fixed thread count)
forked:     yes (variable process count)

这很奇怪,所以我认为

看起来像Apache改变了什么,所以似乎必须指定mpm模式,所以如果我把Apache编译成--with-mpm=prefork,这似乎是有效的。

./configure --enable-proxy --enable-rewrite --enable-headers --enable-ssl --with-apr=/usr/local/apr/  --with-mpm=prefork

最新更新