Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:44507 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 90125 invoked from network); 27 Jun 2009 00:41:06 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 27 Jun 2009 00:41:06 -0000 Authentication-Results: pb1.pair.com smtp.mail=ilia@prohost.org; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=ilia@prohost.org; sender-id=unknown Received-SPF: error (pb1.pair.com: domain prohost.org from 209.85.221.198 cause and error) X-PHP-List-Original-Sender: ilia@prohost.org X-Host-Fingerprint: 209.85.221.198 mail-qy0-f198.google.com Received: from [209.85.221.198] ([209.85.221.198:42224] helo=mail-qy0-f198.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 2C/BF-08868-1AA654A4 for ; Fri, 26 Jun 2009 20:41:06 -0400 Received: by qyk36 with SMTP id 36so3594163qyk.29 for ; Fri, 26 Jun 2009 17:41:02 -0700 (PDT) Received: by 10.224.3.4 with SMTP id 4mr3585491qal.210.1246063262764; Fri, 26 Jun 2009 17:41:02 -0700 (PDT) Received: from ?192.168.1.132? (CPE0018f8c0ee69-CM000f9f7d6664.cpe.net.cable.rogers.com [99.238.11.214]) by mx.google.com with ESMTPS id 4sm8657641qwe.8.2009.06.26.17.40.49 (version=TLSv1/SSLv3 cipher=RC4-MD5); Fri, 26 Jun 2009 17:40:59 -0700 (PDT) Cc: Scott MacVicar , Pierre Joye , Lukas Smith , Rasmus Lerdorf Message-ID: To: PHP internals In-Reply-To: <4A4566BD.4000109@lerdorf.com> Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes Content-Transfer-Encoding: 7bit Mime-Version: 1.0 (Apple Message framework v935.3) Date: Fri, 26 Jun 2009 20:40:48 -0400 References: <9A46F4B8-E64A-4C3C-B2A5-FC354A3EB71D@pooteeweet.org> <0C2F23C2-D188-4938-B44C-4ED166B934CE@macvicar.net> <4A451D6A.8090102@lerdorf.com> <4A454583.9000801@lerdorf.com> <901C4626-24FD-46A6-A116-7B9502FCD67D@prohost.org> <4A4566BD.4000109@lerdorf.com> X-Mailer: Apple Mail (2.935.3) Subject: Re: [PHP-DEV] post 5.3.0 development From: ilia@prohost.org (Ilia Alshanetsky) After some conversations with Rasmus on IRC i've come up with the following patch: http://ilia.ws/patch/curl.txt This basically forces flush() on the header & output streams right after curl_exec(), this ensures that the data retrieved by curl is synched to disk. The patch is also self contained to curl so no external elements are affected by the patch. Ilia Alshanetsky On 26-Jun-09, at 8:24 PM, Rasmus Lerdorf wrote: > Just to keep the list in synch with the irc discussion. I pointed out > that this is only half of the fix. The refcount still prevents fclose > from flushing the data, so if you do: > > $url = 'http://slowgeek.com/test.xml'; > $cfile = 'out.xml'; > $ch = curl_init($url); > curl_setopt($ch, CURLOPT_FILE, $fp = fopen($cfile,'w')); > $status = curl_exec($ch); > fclose($fp); > $data = file_get_contents($cfile); > var_dump($data); // 0 bytes here > curl_close($ch); > $data = file_get_contents($cfile); > var_dump($data); // full contents here > > I still think we need to look at doing a flush on an fclose which > doesn't reach the stream destructor due to refcount issues. > > Can anybody think of any side-effects of a flush on a stream close? > > -Rasmus