[Patch/RFC] Fix libstdc++/9533
Paolo Carlini
pcarlini@unitus.it
Tue Mar 18 13:19:00 GMT 2003
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.
More information about the Libstdc++
mailing list