This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [Patch] Fix libstdc++/9533


On Mon, Mar 03, 2003 at 07:27:14PM +0100, Paolo Carlini wrote:
> the below, which is the result of today's exchanges with P?tur,
> fixes the problem by setting O_NONBLOCK only for initializing the
> buffer, otherwise leaving O_NONBLOCK clear, as explained by Nathan.
> ...
> +
> +  void
> +#if defined (F_SETFL) && defined (F_GETFL) && defined (O_NONBLOCK)
> +  __basic_file<char>::no_block(int& __fdflags)
> +#else
> +  __basic_file<char>::no_block(int&)
> +#endif
> +  {
> +    if (this->is_open())
> +      {
> +#if defined (F_SETFL) && defined (F_GETFL) && defined (O_NONBLOCK)
> +	__fdflags = fcntl(this->fd(), F_GETFL);
> +	fcntl(this->fd(), F_SETFL, O_NONBLOCK);
> +#endif
> +      }
> +  }

This looks incomplete to me.  I would expect the if statement to be 
in the #if block.  (Likewise in block().)  Also, I would expect to 
see (O_NONBLOCK | __fdflags) passed to fcntl.  Why return the flags
via int& instead of by function return?  fcntl should be called as 
::fcntl.  (Likewise other system calls.  Do we have a policy yet?)  
Finally, mustn't these members' names be uglified, e.g. _M_no_block
etc.?

It's not clear to me why the non-blocking read is needed at all,
or why we're reading on open.  Why not wait to read until somebody
wants to see some bytes, and just leave the buffer empty until then?
(Apologies if this has been discussed at length already.)

Nathan Myers
ncm-nospam at cantrip dot org


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]