Don't buffer in IoWrite(), indicate that fwrite() returns size_t, not ssize_t.

This commit is contained in:
Jordan Bancino 2023-03-16 14:17:04 +00:00
parent 6ee1857f5f
commit e0a3760a37
2 changed files with 10 additions and 3 deletions

View file

@ -14,8 +14,8 @@ Milestone: v0.3.0
[~] Stream API
[~] Implementation
[ ] Convert all code that deals with I/O
[ ] Multi-output (proof of concept)
[ ] Memory streams (proof of concept)
[!] Multi-output (proof of concept)
[!] Memory streams (proof of concept)
[ ] TLS
[ ] SOCKS
[x] Move/convert UtilStreamCopy()

View file

@ -37,8 +37,15 @@ static ssize_t
IoWriteFile(void *cookie, void *buf, size_t nBytes)
{
FILE *fp = cookie;
size_t res = fwrite(buf, 1, nBytes, fp);
return fwrite(buf, 1, nBytes, fp);
/*
* fwrite() may be buffered on some platforms, but at this low level,
* it should not be; buffering happens in Stream, not Io.
*/
fflush(fp);
return res;
}
static off_t