You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@apr.apache.org by Joe Schaefer <jo...@sunstarsys.com> on 2005/03/10 16:01:37 UTC
Portability of apr_file_writev_full?
apreq has a similar function, and some questions
came up yesterday regarding its implementation. So
I took a look at the recent apr implementation,
and I have a few questions of my own regarding this loop:
do {
apr_size_t i, amt;
status = apr_file_writev(thefile, vec, nvec, &amt);
/* We assume that writev will only write complete iovec areas.
* Incomplete writes inside a single area are not supported.
* This should be safe according to SuS v2.
*/
for (i = 0; i < nvec; i++) {
total += vec[i].iov_len;
if (total >= amt) {
vec = &vec[i+1];
nvec -= i+1;
break;
}
}
} while (status == APR_SUCCESS && nvec > 0);
First, this is the only implementation I could find in apr,
so I assume its being used on non-unix platforms where SuS v2
does not apply, particularly wrt writev() itself.
Second, I disagree that SuS v2 makes any guarantees about writev()
only writing "complete iovec areas". I assume a conforming writev()
implementation can hand the single-iovec case off to write(). So if
there's more data in the iovec than the target device can accept,
it winds up doing a partial write, successfully.
IMO the statement in SuS: "the writev() function shall always write a
complete area before proceeding to the next" should be interpreted
conservatively: the implementation isn't allowed to move on to the
next iovec, unless it can write all of the current one.
--
Joe Schaefer
Re: Portability of apr_file_writev_full?
Posted by Paul Querna <ch...@force-elite.com>.
Joe Orton wrote:
> On Thu, Mar 10, 2005 at 10:01:37AM -0500, Joe Schaefer wrote:
> ...
>
>>Second, I disagree that SuS v2 makes any guarantees about writev()
>>only writing "complete iovec areas". I assume a conforming writev()
>>implementation can hand the single-iovec case off to write(). So if
>>there's more data in the iovec than the target device can accept,
>>it winds up doing a partial write, successfully.
>
>
> Yes it's broken as you indicate, I pointed this out when it was
> committed... this had dropped off my radar at least. It needs to call
> apr_file_write_full to complete writing any partially-written buffer, or
> something like that.
Yep, my fault. It dropped off my radar too. I will try to fix it this
weekend.
-Paul
Re: Portability of apr_file_writev_full?
Posted by Joe Orton <jo...@redhat.com>.
On Thu, Mar 10, 2005 at 10:01:37AM -0500, Joe Schaefer wrote:
...
> Second, I disagree that SuS v2 makes any guarantees about writev()
> only writing "complete iovec areas". I assume a conforming writev()
> implementation can hand the single-iovec case off to write(). So if
> there's more data in the iovec than the target device can accept,
> it winds up doing a partial write, successfully.
Yes it's broken as you indicate, I pointed this out when it was
committed... this had dropped off my radar at least. It needs to call
apr_file_write_full to complete writing any partially-written buffer, or
something like that.
joe