Do we need php_stream_error? (was: Re: [PHP-DEV] Streams segfault)

From: Date: Fri, 23 Aug 2002 19:41:08 +0000
Subject: Do we need php_stream_error? (was: Re: [PHP-DEV] Streams segfault)
References: 1  Groups: php.dev 
Request: Send a blank email to php-dev+get-87365@lists.php.net to get a copy of this message
Having just taken a quick look into implementing php_stream_error, my personal preference is to nuke it - this is my reasoning: o ferror() is only present to differentiate between EOF and an error after an fread()/fwrite(). This can be accomplished by checking php_stream_eof when you get a zero return from those functions. o In my experience (8 years of C), I've only ever needed feof() and not ferror(). o Hardly any code in the PHP codebase uses or used ferror/php_stream_error o Making stdio based streams respect the equivalent error state of the FILE* means sticking extra assignments into the abstraction: stream->error = ferror(data->file), which is ugly and saps CPU cycles. o The alternative is to implement php_stream_error as a "method" in the abstraction. This would make the error condition check "slow", but easier to implement. o The semantics of PHP streams were "designed" without the need for php_stream_error; they are supposed to similar to ANSI stdio in many cases, but not identical. What are your opinions? --Wez. On 08/23/02, "Rasmus Lerdorf" <rasmus@php.net> wrote: > Yeah, that's why I am asking. In the ftp extension we have: > > if (ret != PHP_FTP_MOREDATA && ftp->closestream) { > php_stream_close(ftp->stream); > } > if (ret == PHP_FTP_FAILED || php_stream_error(ftp->stream)) { > php_error(E_WARNING, "%s(): %s", get_active_function_name(TSRMLS_C), > ftp->inbuf); > } > > Seemed to me that this would turn into a problem once php_stream_error() > is implemented. > On Fri, 23 Aug 2002, Wez Furlong wrote: > > No; once closed, a stream is pefree()d - just like a FILE*. > > Also, php_stream_error is currently a NOP: > > On 08/23/02, "Rasmus Lerdorf" <rasmus@php.net> wrote: > > > Can we call php_stream_error() on a closed stream?

« previous php.dev (#87365) next »