This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Re: [Patch/RFC] Fix libstdc++/9533
- From: Paolo Carlini <pcarlini at unitus dot it>
- To: Benjamin Kosnik <bkoz at redhat dot com>
- Cc: libstdc++ at gcc dot gnu dot org, Nathan Myers <ncm at cantrip dot org>
- Date: Tue, 18 Mar 2003 14:19:59 +0100
- Subject: Re: [Patch/RFC] Fix libstdc++/9533
- References: <3E707F98.6080109@unitus.it> <20030317140851.4430d656.bkoz@redhat.com>
Hi again,
a couple of comments on Ulrich reply:
That's a common problem. The in_avail function should, in case the read
buffer is empty, use poll or select.
I think he really mean showmanyc, _not_ in_avail: in_avail can only do
something very simple along the lines (Nathan's code. Soon more about it:
in fact using the code below fixes the 2nd half of 9701 without
regressions):
stremsize
in_avail()
{
streamsize __ret = this->egptr() - this->gptr();
return (__ret != 0) ? __ret : this->showmanyc();
}
I think using fcntl() to select
non-blocking mode isn't that good since it affects duplicates of the
file descriptor.
if (read-buffer not empty)
return true;
struct pollfd pfd[1];
pfd[0].fd = ifs.fileno();
pfd[0].events = POLLIN;
if (poll (pfd, 1, 0) > 0)
return true;
return false;
Interesting. However what we really need inside showmanyc is an estimate
of the _number_ of externally available chars.
How possibly poll can return such a number?
Paolo.