This is the mail archive of the
mailing list for the libstdc++ project.
Re: [Patch] Fix libstdc++/11378 (3rd take)
- From: Nathan Myers <ncm-nospam at cantrip dot org>
- To: libstdc++ at gcc dot gnu dot org
- Date: Sat, 12 Jul 2003 09:42:18 -0700
- Subject: Re: [Patch] Fix libstdc++/11378 (3rd take)
- References: <3F0FF666.email@example.com>
On Sat, Jul 12, 2003 at 01:52:06PM +0200, Paolo Carlini wrote:
> this is the 3rd try: in this case I have added an autoconf
> test for writev, which is then used when available, as per
> Nathan's indication.
> I would really like to have this in and close 11378 once
> and for all.
Wow, that's fast work! Looks clean too.
There is one thing left, though. writev() (like write()) is allowed
to return a "short write", writing less than was asked, and we're
supposed to call it again until it either finishes or fails to make
progress. That means a loop in, or around the call to, xsputn_2.
If it writes only part of the internal buffer before failing, we
probably should memmove() the rest of the internal buffer back to
the beginning and update pptr() accordingly. Finally, overflow()
should behave similarly, which also means __basic_file<>::xsputn()
needs a loop too.
I'm sorry that this is seeming to blow up in your face. I only
just noticed the underlying correctness problem. It has to work
right (i.e. not corrupt the streambuf) if write() only ever returns
1 or -1, and if it returns 1 and then -1. That makes the code
Getting that right with multibyte character encodings will be a
separate exercise, using some of the same algorithms involved in
seeking. First let's get the noconv case right.