delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/2003/01/24/04:04:38

X-Sybari-Trust: ac5128bf 9ffcebbb c096fb41 00000138
From: Martin Stromberg <eplmst AT epl DOT ericsson DOT se>
Message-Id: <200301240901.KAA06785@lws256.lu.erisoft.se>
Subject: Re: readv, writev [PATCH]
To: djgpp-workers AT delorie DOT com
Date: Fri, 24 Jan 2003 10:01:25 +0100 (MET)
In-Reply-To: <3E305173.9E89FA57@phekda.freeserve.co.uk> from "Richard Dawe" at Jan 23, 2003 08:32:52 PM
X-Mailer: ELM [version 2.5 PL3]
MIME-Version: 1.0
Reply-To: djgpp-workers AT delorie DOT com
Errors-To: nobody AT delorie DOT com
X-Mailing-List: djgpp-workers AT delorie DOT com
X-Unsubscribes-To: listserv AT delorie DOT com

Richard said:
> But if write() fails, then the file pointer is not advanced. Consider writev()
> for a vector of 2 entries, if we write() iovec-by-iovec:
> 
> Entry 1: write() succeeds
> Entry 2: write() fails
> 
> If we want to fail writev(), because the second write fails, then we should
> seek to the position before writev() was called.

Why do we want to fail the writev() call? It clearly succeeded in
writing the bytes it wrote from Entry 1.

I just don't get it.

Consider these cases which with your reasoning would be failures:

A. write(fd, buf, 100) returns 50. It partially wrote it. Success.

B. Your example above. It partially wrote it. Success.

C. writev(): Entry 1: write(fd, buf, 100) returns 50. It partially
			wrote it.
             Entry 2: don't bother. We could only write 50 of 100
			before.
             In total success (we wrote something), return 50.

D. writev(): Entry 1: write(fd, buf, 100) succeeds returning 100.
             Entry 2: write(fd, buf, 100) returns 50. It partially
			wrote it.
             In total success (we wrote something), return 100+50.


Tha failure case:
If (and only if) the first write() call in writev() fails, writev()
fails.

> OK, now I'm slightly embarrassed. This is also the first time I've looked at
> the Cygwin source and they seem to use the memory allocation method too.

Why? As the licenses differ (I think), I'd be very wary of looking
there.


Right,

						MartinS

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019