Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:51570 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 95931 invoked from network); 4 Mar 2011 18:48:26 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 4 Mar 2011 18:48:26 -0000 Authentication-Results: pb1.pair.com smtp.mail=glopes@nebm.ist.utl.pt; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=glopes@nebm.ist.utl.pt; sender-id=unknown Received-SPF: error (pb1.pair.com: domain nebm.ist.utl.pt from 193.136.128.22 cause and error) X-PHP-List-Original-Sender: glopes@nebm.ist.utl.pt X-Host-Fingerprint: 193.136.128.22 smtp2.ist.utl.pt Linux 2.6 Received: from [193.136.128.22] ([193.136.128.22:36829] helo=smtp2.ist.utl.pt) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 36/C3-11441-7F3317D4 for ; Fri, 04 Mar 2011 13:48:24 -0500 Received: from localhost (localhost.localdomain [127.0.0.1]) by smtp2.ist.utl.pt (Postfix) with ESMTP id 391377000496 for ; Fri, 4 Mar 2011 18:48:20 +0000 (WET) X-Virus-Scanned: by amavisd-new-2.6.4 (20090625) (Debian) at ist.utl.pt Received: from smtp2.ist.utl.pt ([127.0.0.1]) by localhost (smtp2.ist.utl.pt [127.0.0.1]) (amavisd-new, port 10025) with LMTP id rn7qxquwM34V for ; Fri, 4 Mar 2011 18:48:19 +0000 (WET) Received: from mail2.ist.utl.pt (mail.ist.utl.pt [IPv6:2001:690:2100:1::8]) by smtp2.ist.utl.pt (Postfix) with ESMTP id 85EFA700048E for ; Fri, 4 Mar 2011 18:48:19 +0000 (WET) Received: from cataphract-old.dulce.lo.geleia.net (cataphract-old.dulce.lo.geleia.net [IPv6:2001:470:94a2:2:9978:6e7:759:40ee]) (Authenticated sender: ist155741) by mail2.ist.utl.pt (Postfix) with ESMTPSA id 934102008D42 for ; Fri, 4 Mar 2011 18:48:18 +0000 (WET) Content-Type: text/plain; charset=utf-8; format=flowed; delsp=yes To: internals@lists.php.net References: <4D703FBC.3080006@sugarcrm.com> Date: Fri, 04 Mar 2011 18:48:04 -0000 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Organization: =?utf-8?Q?N=C3=BAcleo_de_Eng=2E_Biom=C3=A9di?= =?utf-8?Q?ca_do_IST?= Message-ID: In-Reply-To: <4D703FBC.3080006@sugarcrm.com> User-Agent: Opera Mail/11.01 (Win32) Subject: Re: [PHP-DEV] streams problem in 5.3 From: glopes@nebm.ist.utl.pt ("Gustavo Lopes") On Fri, 04 Mar 2011 01:26:20 -0000, Stas Malyshev wrote: > I try to do some complex code with custom streams and I have discovered > the following problem: > > The code in main/streams/cast.c, specifically _php_stream_cast, creates > fopencookie() synthetic stream for streams that are not actual file > streams. Which works fine until such stream is used in include(), in > which case it ultimately arrives at zend_stream_fixup(). Which would in > turn call zend_stream_fsize() - which would do > fstat(fileno(file_handle->handle.fp), &buf) - and that would fail since > you can't get fileno for FILE* created by fopencookie. > Which ultimately means I can't use my custom streams for include(), > which is bad. Now, looking at the code, it doesn't actually need the > exact size - http streams can be included just fine - but insists on > having it if it has fp (which it can have for basically any kind of > stream due to the cookie trick). Does anyone has any idea why and if it > can be fixed? Can you tell what exactly you're doing? Why is there any cast in the first place? As far as I can see, the include should eventually call php_stream_open_for_zend_ex, which should give a ZEND_HANDLE_STREAM file handle that defers reading to _php_stream_read and fsize to php_zend_stream_fsizer, with no casting involved. -- Gustavo Lopes