[Toybox] [PATCH] xputs: Do flush
Yi-Yo Chiang
yochiang at google.com
Sat May 18 19:53:21 PDT 2024
What I wanted to address with this patch are:
1. Fix this line of xputs()
https://github.com/landley/toybox/blob/master/toys/net/microcom.c#L113
The prompt text is not flushed immediately, so it is not shown to the user
until the escape char is entered (which defeats the purpose of the prompt,
that is to tell the user what the escape char is) and stdout is flushed
by handle_esc.
To fix this we either make xputs() flush automatically, or we just add a
single line of manual flush() after xputs() in microcom.c.
Either is fine with me.
2. The comment string before xputs() is misleading and I wanted to fix that.
I was misled by the comment line, and incorrectly thought xputs() was
flushing. I only discovered otherwise after iterations of trial-and-error.
To fix this is to either make xputs() flush automatically, or just update
the comment string to clarify that xputs() does _not_ flush.
Again either path is fine with me. I just merged the fixes of the two
problems into one because they share the former solution. Plus xputsl() and
xputsn() are also flushing, so I thought / believed xputs() was
mistakenly made non-flushing.
Since the intention _is_ to keep xputs() non-flushing, how about we just
update the comment of xputs() (2), and add the line of flush in microcom.c
(1)?
On Sun, May 19, 2024 at 8:41 AM Rob Landley <rob at landley.net> wrote:
> On 5/16/24 06:46, Yi-Yo Chiang via Toybox wrote:
> > The comment string claims xputs() to write, flush and check error.
> > However the 'flush' operation is actually missing due to 3e0e8c6
> > changing the default buffering mode from 'line' to 'block'.
>
> That's sort of an Elliott question?
>
> Originally, xprintf() and friends all flushed (which is necessary to detect
> output errors and xexit() if so), but Elliott complained that was too
> slow, so
> the flushes got removed, and then we changed the default stdout buffering
> type,
> and...
>
> Alas, it was a whole multi-year thing. Elliott has volunteered to put
> manual
> flushes everywhere it's a problem. I've seriously thought about going
> exclusively to file descriptor output (dprintf() is in posix now) and
> leaving
> FILE * for input only.
>
> Personally, I honestly believe the _proper_ fix is to upgrade the kernel
> to use
> vdso to implement nagle's algorithm on file descriptor 1:
>
> https://landley.net/notes-2024.html#28-04-2024
>
> But I'm not holding my breath.
>
> Rob
>
> P.S. I should post some subset of
> https://landley.net/bin/mkroot/latest/linux-patches/ to linux-kernel
> again. So
> they can be ignored again.
> _______________________________________________
> Toybox mailing list
> Toybox at lists.landley.net
> http://lists.landley.net/listinfo.cgi/toybox-landley.net
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.landley.net/pipermail/toybox-landley.net/attachments/20240519/83d05ce2/attachment.htm>
More information about the Toybox
mailing list