为什么我的节变量有时仅在 mod_perl 下可用?
在 httpd.conf 中,我有:
<Perl>
$MyPackage::foo = { ... };
</Perl>
根据文档,这应该(因为它是合格的)保留到我的 perl 脚本中,这些脚本是与 modperl 处理程序一起运行的。 有时他们会这样做。 但随后我需要做的就是触摸 MyPackage.pm,突然间 $MyPackage::foo 现在是 undef 了。 重新启动网络服务器,它又可以工作了。
有谁能帮我止住眼泪吗?
我最好的猜测是,当解析 .conf 时,该块仅运行一次,然后新线程会拾取重新加载的文件。 但为什么每个线程不运行一次呢? 除了 $ENV 和自定义指令之外,我是否可以使用每个服务器只加载一次然后复制到所有解释器的东西? (我可能在最后使用了错误的术语,但你明白了。)
In httpd.conf I have:
<Perl>
$MyPackage::foo = { ... };
</Perl>
According to the docs, this should, since it's qualified, persist into my perl scripts, which are run with the modperl handler. And sometimes they do. But then all I need to do is touch MyPackage.pm, and all of the sudden $MyPackage::foo is now undef. Restart the web server, and it works again.
Anybody have an end to my tears?
My best guess is that the block only gets run once, when the .conf is parsed, and then a new thread picks up the reloaded file. But why doesn't it get run once per thread? Isn't there something I can use besides $ENV and custom directives that gets loaded exactly once per server, and then copied to all interpreters? (I'm probably using the wrong terminology at the end here, but you get the idea.)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我在打字时想到了这一点,但我想我会分享,以防它拯救其他人我刚刚拔掉的头发。
最简单的解决方案是将 .conf 中的作用域变量重命名为您实际未使用的内容:
...然后让您的实际包选择它:
当我测试它时,这似乎一直有效。
I figured this out while typing it up, but thought I would share in case it saved anyone else the hairs I just pulled out.
The easiest solution is to rename the scoped variable in the .conf to something you're not actually using:
...and then have your actual package pick it up:
This seems to have worked consistently when I tested it.