rolling-curl
rolling-curl copied to clipboard
Bug in pruning pending request queue
Hi,
I just found that prunePendingRequestQueue does not work as it should, it always return empty list because of a bug in getNextPendingRequests. Please see this code:
private function getNextPendingRequests($limit = 1)
{
$requests = array();
while ($limit--) {
if (!isset($this->pendingRequests[$this->pendingRequestsPosition])) {
break;
}
$requests[] = $this->pendingRequests[$this->pendingRequestsPosition];
$this->pendingRequestsPosition++;
}
return $requests;
}
If $limit is 0, the while loop will never run. I propose this patch to fix this bug:
- while ($limit--) {
+ $countPending = $limit <= 0 ? $this->countPending() : $limit;
+ while ($countPending--) {
Fixed it for me and made it work, so +1 ;)
Can I use GET and PUT request in parallel ?
@solidfoxrock, thank you for sharing this. I just had this bug reported on one of my projects and you had the fix already! too bad this wasn't already implemented into the project.