Skip to content

Commit

Permalink
Merge pull request #68 from ccurdt/master
Browse files Browse the repository at this point in the history
fixed memory leak during connection setup
  • Loading branch information
nervetattoo committed Oct 15, 2017
2 parents 90cd167 + d033461 commit 668d029
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/ElasticSearch/Transport/HTTP.php
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 668d029

Please sign in to comment.