简体   繁体   English

perl Apache2 ::同时使用param()和upload()方法请求错误

[英]perl Apache2::Request errors using param() and upload() methods simultaneously

I'm coding in a mod_perl environment and using the Apache2::Request module to get posted data. 我在mod_perl环境中编码并使用Apache2 :: Request模块获取发布的数据。 This works fine, except for when I also use the Apache2::Request object also to upload a file/get the file's filehandle. 这工作正常,除了我还使用Apache2 :: Request对象上传文件/获取文件的文件句柄。 If use the methods separately, there are no issues. 如果单独使用这些方法,则没有问题。 However, if I use them both in the same subroutine, I get this error in my Apache log file: 但是,如果我在同一子例程中使用它们,我会在Apache日志文件中出现此错误:

[notice] child pid 27383 exit signal Segmentation fault (11)

Here is my code: 这是我的代码:

my $r = shift;
use Apache2::Request;
use Apache2::Upload;
my $req = Apache2::Request->new($r, POST_MAX => 10 * 1024 * 1024,DISABLE_UPLOADS => 0);
my $img_url = $req->param('url');

my $upload = $req->upload('files[]');
my $filename = $upload->filename;
my $upload_filehandle = $upload->fh;
my $file_size = $upload->size;

Apache2::Upload is included because it is used by Apache2::Request. 包含Apache2 :: Upload,因为Apache2 :: Request使用它。 Like I said, if I comment out either the line that begins with "my $img_url.." or the upload section, it works fine. 就像我说的,如果我注释掉以“my $ img_url ..”开头的行或上传部分,它就可以了。 However, if they are both present in the code, I get a 502 Proxy Error and that error in the apache log file. 但是,如果它们都存在于代码中,则会在apache日志文件中出现502 Proxy Error和该错误。

Thanks in advance! 提前致谢!

I appreciate this is an old question so my reply is a little late, but in case anyone else stumbles across this thread I do have a solution. 我很欣赏这是一个老问题,所以我的回复有点晚了,但是如果有其他人偶然发现这个帖子,我确实有一个解决方案。

The problem is a mod_perl bug with New(): 问题是New()的mod_perl错误:

my $req = Apache2::Request->New($r);

(in your case, you have a few other things defined in there, but it looks to be the same segfaults and sporadic symptoms that I was suffering from). (在你的情况下,你在那里定义了一些其他的东西,但它看起来是我遇到的相同的段错误和零星的症状)。

Apache2::Request segfaults when $r isn't define, but sometimes it seems to segfault even when you've shifted @_ into $r (as you have done). 当$ r未定义时,Apache2 ::请求段错误,但有时即使你将@_转换为$ r(如你所做的那样),它似乎也会出现段错误。 I can't explain why this happens, but I have found a simple change that has stopped this issue from happening: 我无法解释为什么会发生这种情况,但我发现了一个简单的改变,阻止了这个问题的发生:

my $req = Apache2::Request->New(Apache2::RequestUtil->request);

So your code would presumably read as follows: 因此,您的代码可能会如下所示:

my $req = Apache2::Request->new(Apache2::RequestUtil->request,
                                POST_MAX => 10 * 1024 * 1024,
                                DISABLE_UPLOADS => 0);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM