Skip to content

Commit

Permalink
select timeout fix
Browse files Browse the repository at this point in the history
  • Loading branch information
walkor committed Jan 21, 2015
1 parent 5aa7716 commit 9a9163a
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
2 changes: 1 addition & 1 deletion applications/Statistics/Lib/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ function multiRequest($request_buffer_array)
// 轮询处理数据
while(count($read) > 0)
{
if(stream_select($read, $write, $except, 0, 200000))
if(@stream_select($read, $write, $except, 0, 200000))
{
foreach($read as $socket)
{
Expand Down
2 changes: 1 addition & 1 deletion workerman/Common/Protocols/Http/Http.php
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ function http_start($http_string, $SERVER = array())
// 需要解析$_POST
if($_SERVER['REQUEST_METHOD'] == 'POST')
{
if($_SERVER['CONTENT_TYPE'] == 'multipart/form-data')
if(isset($_SERVER['CONTENT_TYPE']) && $_SERVER['CONTENT_TYPE'] == 'multipart/form-data')
{
parse_upload_files($http_body, $http_post_boundary);
}
Expand Down
16 changes: 15 additions & 1 deletion workerman/Core/Events/Select.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,20 @@ class Select implements BaseEvent
*/
public $writeFds = array();

/**
* 构造函数 创建一个管道,避免select空fd
* @return void
*/
public function __construct()
{
$this->channel = stream_socket_pair(STREAM_PF_UNIX, STREAM_SOCK_STREAM, STREAM_IPPROTO_IP);
if($this->channel)
{
stream_set_blocking($this->channel[0], 0);
$this->readFds[0] = $this->channel[0];
}
}

/**
* 添加事件
* @see \Man\Core\Events\BaseEvent::add()
Expand Down Expand Up @@ -121,7 +135,7 @@ public function loop()
// 触发信号处理函数
pcntl_signal_dispatch();
// stream_select false:出错 ; 0:超时
if(!($ret = @stream_select($read, $write, $e, PHP_INT_MAX)))
if(!($ret = @stream_select($read, $write, $e, 60)))
{
// 超时
if($ret === 0)
Expand Down

0 comments on commit 9a9163a

Please sign in to comment.