rolling-curl icon indicating copy to clipboard operation
rolling-curl copied to clipboard

Bug in pruning pending request queue

Open sudokien opened this issue 10 years ago • 3 comments

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--) {

sudokien avatar Mar 28 '15 07:03 sudokien

Fixed it for me and made it work, so +1 ;)

janpio avatar Mar 30 '15 15:03 janpio

Can I use GET and PUT request in parallel ?

iit2011081 avatar May 11 '15 13:05 iit2011081

@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.

ghost avatar Mar 12 '18 01:03 ghost