我在这里发布我的解决方案。
问题:
我的情况是,我的服务器自动更新某些内容时,会影响某些功能来处理多个cUrl请求。
解决方案:
我正在使用 Yii Framework ,并且在我的项目中使用 guzzlehttp 供应商。这个模块提出了这个问题。所以我评论了一段代码来解决这个问题。
打开文件。
vendor / guzzlehttp / guzzle / src / Handler / CurlFactory.php
转到功能发布
并注释以下几行。
if (count($this->handles) >= $this->maxHandles) {
curl_close($resource);
} else {
// Remove all callback functions as they can hold onto references
// and are not cleaned up by curl_reset. Using curl_setopt_array
// does not work for some reason,so removing each one
// individually.
curl_setopt($resource,CURLOPT_HEADERFUNCTION,null);
curl_setopt($resource,CURLOPT_READFUNCTION,CURLOPT_WRITEFUNCTION,CURLOPT_PROGRESSFUNCTION,null);
curl_reset($resource);
$this->handles[] = $resource;
}
并添加以下行代替
curl_close($resource);
应用解决方案后,请参阅完整的功能。
public function release(EasyHandle $easy)
{
$resource = $easy->handle;
unset($easy->handle);
/*if (count($this->handles) >= $this->maxHandles) {
curl_close($resource);
} else {
// Remove all callback functions as they can hold onto references
// and are not cleaned up by curl_reset. Using curl_setopt_array
// does not work for some reason,so removing each one
// individually.
curl_setopt($resource,null);
curl_setopt($resource,null);
curl_reset($resource);
$this->handles[] = $resource;
}*/
curl_close($resource);
}
我希望它能对您有所帮助。
本文链接:https://www.f2er.com/2408416.html