public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "ncm-nospam at cantrip dot org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug libstdc++/21286] [4.0/4.1 Regression] filebuf::xsgetn vs pipes
Date: Sat, 30 Apr 2005 02:12:00 -0000	[thread overview]
Message-ID: <20050430021151.763.qmail@sourceware.org> (raw)
In-Reply-To: <20050429155408.21286.ralfixx@gmx.de>


------- Additional Comments From ncm-nospam at cantrip dot org  2005-04-30 02:11 -------
Just to add... if sgetn() loops reading until it gets n bytes, but 
underflow() accepts a pipe's short reads, then in_avail() will report 
the size of the short read.  Then, istream::read_some() will 
rdbuf->sgetn(p,rdbuf->in_avail()), thus matching POSIX pipe semantics 
when attached to a pipe.

(For those who don't know: as long as whoever is writing the
other end of the pipe writes no more than PIPE_BUF bytes into 
it, then POSIX requires that read() deliver the bytes on write 
boundaries.  Thus, if you're writing structs, the reader will 
see half a struct.  If you're writing short-enough lines, the 
reader will only ever see complete lines -- although you might
see more than one.  Watch out that PIPE_BUF is 4K or more 
on Linux, but only 512 bytes on BSD!)

It's exciting to finally get this right.  With a bit more work, 
I see now that we might be able to support nonblocking file 
descriptors, and maybe even zero-copy I/O, too!  Thank you, Ralf.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21286


  parent reply	other threads:[~2005-04-30  2:12 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-04-29 15:54 [Bug c++/21286] New: GNU extension stdio_filebuf problems when reading from pipe ralfixx at gmx dot de
2005-04-29 15:56 ` [Bug c++/21286] " ralfixx at gmx dot de
2005-04-29 15:58 ` ralfixx at gmx dot de
2005-04-29 17:28 ` pcarlini at suse dot de
2005-04-29 21:31 ` [Bug libstdc++/21286] " pcarlini at suse dot de
2005-04-30  2:12 ` ncm-nospam at cantrip dot org [this message]
2005-04-30  3:49 ` [Bug libstdc++/21286] [4.0/4.1 Regression] filebuf::xsgetn vs pipes ncm-nospam at cantrip dot org
2005-04-30  6:54 ` cvs-commit at gcc dot gnu dot org
2005-04-30  8:00 ` pcarlini at suse dot de
2005-04-30 14:16 ` ralfixx at gmx dot de
2005-04-30 15:49 ` ncm-nospam at cantrip dot org
2005-04-30 22:56 ` cvs-commit at gcc dot gnu dot org
2005-04-30 22:57 ` pcarlini at suse dot de
2005-05-01 17:44 ` ralfixx at gmx dot de
2005-05-01 18:12 ` pcarlini at suse dot de
2005-05-01 19:12 ` ralfixx at gmx dot de
2005-05-01 19:28 ` pcarlini at suse dot de
2005-07-14 20:53 ` amu at alum dot mit dot edu
2005-07-14 23:58 ` pcarlini at suse dot de
2005-07-18 12:17 ` ralfixx at gmx dot de
2005-07-18 12:46 ` pcarlini at suse dot de
2005-07-18 15:02 ` ralfixx at gmx dot de
2005-07-18 17:08 ` pcarlini at suse dot de
2005-07-18 18:35 ` cvs-commit at gcc dot gnu dot org
2005-07-18 18:40 ` [Bug libstdc++/21286] [3.4/4.0/4.1 " pcarlini at suse dot de
2005-07-18 18:51 ` pcarlini at suse dot de

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20050430021151.763.qmail@sourceware.org \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).