Skip to content

Commit d279e4b

Browse files
committed
Fix curl file handle not being correctly unset; Clean up
1 parent 512b514 commit d279e4b

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

src/Curl/MultiCurl.php

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -281,17 +281,24 @@ public function start()
281281
// Close open file handles and reset the curl instance.
282282
if (isset($this->curl_fhs[$ch->id])) {
283283
$fh = $this->curl_fhs[$ch->id];
284-
if (!$ch->error) {
284+
285+
if (!$ch->error && $ch->download_complete_function) {
285286
rewind($fh);
286287
$ch->call($ch->download_complete_function, $fh);
287288
}
289+
288290
if (is_resource($fh)) {
289291
fclose($fh);
290292
}
291-
defined('STDOUT') || define('STDOUT', null);
293+
294+
if (!defined('STDOUT')) {
295+
define('STDOUT', null);
296+
}
297+
292298
$ch->setOpt(CURLOPT_FILE, STDOUT);
293299
$ch->setOpt(CURLOPT_RETURNTRANSFER, true);
294-
unset($fh);
300+
301+
unset($this->curl_fhs[$ch->id]);
295302
}
296303
break;
297304
}

0 commit comments

Comments
 (0)