From 00a4c6806afc2df30435412e4b3f3fb8ab0cc213 Mon Sep 17 00:00:00 2001 From: Tristian Flanagan Date: Thu, 14 Apr 2016 11:44:03 -0400 Subject: [PATCH] lib: fixed removing handle when error occurs --- quickbase.php | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/quickbase.php b/quickbase.php index f19a9d8..f9d649d 100644 --- a/quickbase.php +++ b/quickbase.php @@ -111,15 +111,21 @@ final public function api($action, $options = array()){ }while($running > 0); for($i = 0; $i < $nActions; ++$i){ - $queries[$i] - ->processCH() - ->checkForAndHandleError() - ->actionResponse() - ->finalize(); + try { + $queries[$i] + ->processCH() + ->checkForAndHandleError() + ->actionResponse() + ->finalize(); - $results[] = $queries[$i]->response; + $results[] = $queries[$i]->response; - curl_multi_remove_handle($this->mch, $this->chs[$i]); + curl_multi_remove_handle($this->mch, $this->chs[$i]); + }catch(\Exception $err){ + curl_multi_remove_handle($this->mch, $this->chs[$i]); + + throw $err; + } } if($nActions === 1){ @@ -354,7 +360,7 @@ final public function processCH(){ $headerSize = curl_getinfo($this->ch, CURLINFO_HEADER_SIZE); - if($response === false){ + if($response === false || $response === ''){ ++$this->nErrors; if($this->nErrors <= $this->settings['maxErrorRetryAttempts']){