Skip to content

Commit

Permalink
fixed memory leak during connection setup - bad curl opt `returntrans…
Browse files Browse the repository at this point in the history
…fer`, therefore OB instead.
  • Loading branch information
ccurdt authored and ccurdt committed Oct 15, 2017
1 parent 9e1bc35 commit d033461
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/ElasticSearch/Transport/HTTP.php
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,6 @@ protected function call($url, $method="GET", $payload=null) {
curl_setopt($conn, CURLOPT_URL, $requestURL);
curl_setopt($conn, CURLOPT_TIMEOUT, $this->timeout);
curl_setopt($conn, CURLOPT_PORT, $this->port);
curl_setopt($conn, CURLOPT_RETURNTRANSFER, 1) ;
curl_setopt($conn, CURLOPT_CUSTOMREQUEST, strtoupper($method));
curl_setopt($conn, CURLOPT_FORBID_REUSE , 0) ;

Expand All @@ -201,7 +200,10 @@ protected function call($url, $method="GET", $payload=null) {
else
curl_setopt($conn, CURLOPT_POSTFIELDS, $payload);

$response = curl_exec($conn);
// cURL opt returntransfer leaks memory, therefore OB instead.
ob_start();
curl_exec($conn);
$response = ob_get_clean();
if ($response !== false) {
$data = json_decode($response, true);
if (!$data) {
Expand Down

0 comments on commit d033461

Please sign in to comment.