|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2008-05-05 23:04 UTC] iliaa@php.net
[2008-05-09 18:03 UTC] david at acz dot org
[2008-05-09 18:05 UTC] david at acz dot org
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Oct 26 23:00:02 2025 UTC |
Description: ------------ File handles are normally closed automatically when the reference count hits zero. For example, if you fopen() something in a function and only assign it to a local variable, the file is closed when the function returns. CURLOPT_INFILE breaks this behavior. Presumably, the curl resource destructor does not decrement the reference count for the file handle. Reproduce code: --------------- <? $name = tempnam("/tmp", "phpbug"); $n = count(scandir("/proc/self/fd")); test_simple($name); var_dump(count(scandir("/proc/self/fd")) == $n); test_curl($name, true); var_dump(count(scandir("/proc/self/fd")) == $n); test_curl($name, false); var_dump(count(scandir("/proc/self/fd")) == $n); function test_simple($name) { $fp = fopen($name, "r"); } function test_curl($name, $close) { $fp = fopen($name, "r"); $c = curl_init(); curl_setopt($c, CURLOPT_PUT, true); curl_setopt($c, CURLOPT_INFILE, $fp); curl_setopt($c, CURLOPT_INFILESIZE, 0); curl_setopt($c, CURLOPT_RETURNTRANSFER, true); curl_exec($c); curl_close($c); if ($close) fclose($fp); } ?> Expected result: ---------------- bool(true) bool(true) bool(true) Actual result: -------------- bool(true) bool(true) bool(false)