mod fcgid php,php - 'mod_fcgid:从管道读取超时'的fread超时 - 堆栈内存溢出

我的应用程序尝试访问超时的URL存在问题。 我正在尝试捕获此超时并使用此代码解决此问题:

$timeout = 120;

if(false == $handle = @fsockopen($host, $port, $errno, $errstr, $timeout))

{

throw new Exception("Could not connect to url: ".$errstr);

}

$getRequest = "GET {$url} HTTP/1.0\r\n";

$getRequest .= "Host: {$urlParts['host']}\r\n";

$getRequest .= "Connection: close\r\n\r\n";

fwrite($handle, $getRequest);

$maxExecutionTime = ini_get('max_execution_time');

set_time_limit($timeout+10);

stream_set_timeout($handle, $timeout);

$head = fread($handle, 1024); // Read the first 1024 bytes

if($maxExecutionTime == 0) {

$maxExecutionTime = 30;

}

set_time_limit($maxExecutionTime);

$stream_metadata = stream_get_meta_data($handle);

if($stream_metadata['timed_out'] === true) {

throw new Exception("Connection timed out");

}

我用于超时的我的URL是在防火墙后面,所以我无法共享它,但它被设计为sleep()5分钟。 当我尝试运行此代码时,执行将停止在$ head = fread($ handle,1024); 90秒后,我从服务器“脚本过早结束”中得到500错误。 当我在apache日志中调试调试级别时,我看到:

[Fri Aug 26 11:10:45 2011] [warn] [client 192.168.10.202] mod_fcgid: read timeout from pipe

[Fri Aug 26 11:10:45 2011] [error] [client 192.168.10.202] Premature end of script headers: validateUrl.php

'validateUrl.php'是我正在访问此脚本的URL。 我不确定将FcgidIOTimeout增加到更高的值是否安全,因为它适用于我的所有页面。 有什么想法/意见吗?

系统详细信息:在Windows NT上运行的PHP版本5.2.13 EPG-WEB 5.2 build 3790 Apache:Apache / 2.2.19(Win32)mod_fcgid / 2.3.6

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值