net :: ERR_INCOMPLETE_CHUNKED_ENCODING仅在使用pthread时

时间:2014-08-15 19:00:59

标签: php apache google-chrome pthreads chunked-encoding

我正在尝试向网络资源添加线程,以试图加快速度。 一切正常运行1/3的时间。另外2/3导致

net::ERR_INCOMPLETE_CHUNKED_ENCODING 

net::ERR_EMPTY_RESPONSE

这种情况发生在Chrome中(与wget类似的错误),但FireFox和IE运行正常。

页面在100%的时间内没有线程运行时加载正常,但是一旦我引用pthreads库,事情就不能顺利运行

我正在执行的唯一代码更改是:

$aTaskBox = $this->getTaskBox($sUsername, $aTask);
// If the returned task box is not really a task box but a boolean FALSE,
// the task is not to be displayed.  If it is not FALSE, then assume it is
// really a task box and add it to the HTML array.
if ($aTaskBox !== FALSE) {

    $aSectionHTML[$aTaskBox["sCategory"]] .= $aTaskBox["sHTML"];
}

到此:

$tdThread = new TaskBoxThread($this, $sUsername, $aTask, FALSE, FALSE);
$tdThread->start();
$aThreads[] = $tdThread;
...Code emitted...
//Wait for all of threads to finish, and collect the data from them
foreach($aThreads as $tdThread){

    $tdThread->join();
    if($tdThread->sCategory != "Complete"){
        $aSectionHTML[$tdThread->sCategory] .= $tdThread->sHTML;
    }
}

我的线程类:

class TaskBoxThread extends Thread {
    public $sHTML = "";
    //set the category to a defualt value so that errors are not generated later on
    public $sCategory = "Complete";

    public function __construct($oHeadquarters, $sUsername, $aTask, $bCurrentlyInList, $bForProjectView){

        $this->oHeadquarters = $oHeadquarters;
        $this->sUsername = $sUsername;
        $this->aTask = $aTask;
        $this->bCurrentlyInList = $bCurrentlyInList;
        $this->bForProjectView = $bForProjectView;
    }

    public function run(){
        $aBox = $this->oHeadquarters->getTaskBox($this->sUsername, $this->aTask, $this->bCurrentlyInList, $this->bForProjectView);

        // If the returned task box is not really a task box but a boolean FALSE,
        // the task is not to be displayed.  If it is not FALSE, then assume it is
        // really a task box and add it to the HTML array.
        if($aBox != FALSE){

            $this->sCategory = $aBox["sCategory"];
            $this->sHTML = $aBox["sHTML"];
        }
    }
}

代码方面,似乎没有任何可能导致问题的东西,所以我试图用wget抓取页面,这也失败了最后一个字节的字节读取错误,这表明根据分块编码规范发送的最后一个字节不是零,但是当我用wireshark查看数据包时,一切都被正确终止。

我完全不知道接下来会尝试什么,而且我已经在网上搜索过了,那么服务器上的另一个方向是什么导致我可以调查这个问题呢?

编辑:我以为我会再看看代码,当我发表评论时:

$aBox = $this->oHeadquarters->getTaskBox($this->sUsername, $this->aTask, $this->bCurrentlyInList, $this->bForProjectView);

它运行完美,因此我尝试调试该功能。我最后评论了整个功能,只是

$aTaskBox["sHTML"] = "<div>Hi there.</div>";
$aTaskBox["sCategory"] = "WIP";

这是一个简单的函数,但错误仍然存​​在,这让我相信错误与实际的函数调用有关。

0 个答案:

没有答案