NetBSD-Users archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: Problems unpacking sets with ftp -o



I like the fullwrite() abstraction, but I think it should account for the non-zero
return case from reading the fwrite.c code since it seems to return correctly
partial writes. Unfortunately, the underlying __sfvwrite() calls flush()  ->
 _sflush() which is broken (it does not correct the buffer for partial writes,
just errors out). Fortunately FreeBSD has fixed it and I am copying the
fix from them.

Yes, setting non-buffered for the file "fixes" the problem but in reality it just
papers over it. At that point you are not using stdio anymore, you are really
doing write(fileno(fp), buf, len).

Lets fix the fullwrite() abstraction to handle non-zero but less than the full
buffer size returns, keep the clearerr(), I will commit the fix from FreeBSD
and that should fix the issue without needing to do unbuffered I/O.

Best,

christos
> On Jul 5, 2021, at 2:49 AM, RVP <rvp%SDF.ORG@localhost> wrote:
> 
> On Sun, 4 Jul 2021, RVP wrote:
> 
>> +		n = fwrite(p, 1, len, fp);
>> +		if (n == 0) {
>> +			if (errno == EINTR)
>> +				clearerr(fp);
>> +			else
>> +				return 0;
>> +		}
> 
> Small correction: that clearerr() is probably unnecessary--please omit.
> 
> -RVP

Attachment: signature.asc
Description: Message signed with OpenPGP



Home | Main Index | Thread Index | Old Index