flush outputs in wpa_printf
Jouni Malinen
j
Sun Feb 8 10:17:07 PST 2009
On Thu, Feb 05, 2009 at 10:38:23AM +0100, Annie Rota wrote:
> My use case is simpler than what you imagined, I guess. I just needed to
> retrieve the information from wpa_supplicant, and noticed that some outputs
> were never displayed in the clients (wpa_cli stdout, or debug-file output)
> when produced messages do not fill the output buffer, as Dan Williams
> explained in his previous mail.
How do you read the output? Instead of adding explicit flush calls, I
would assume making the stream line buffered would provide suitable
output. This is what happens automatically when the stream is going to
terminal. I do not know how easily this can be controlled by the program
that is reading the output, but that could be a solution that works
without modifying wpa_supplicant.
If the line buffered mode cannot be enabled by whatever is reading the
output, I would prefer a single setlinebuf(f) call and also only when
requested (e.g., command line argument). If I direct the debug output to
a file, I do not want this to add extra latency due to limited
buffering unless I really need to be reading the file all the time.
(actually, since setlinebuf() may not be that portable, setvbuf(f, NULL,
_IOLBF, 0) may be a better way of implementing this)
> Of course, when you enable debug mode (-d -dd), the flow is more important
> and the buffer flushes naturally, but with low traffic output messages, some
> outputs are displayed very late, and the client analysing it can't take any
> decision based on wpa_supplicant feedback, when asynchronous messages are
> involved (eg: when is the pairing done ?).
> Probably I should directly interface to the control interface, but this was
> an easy and simple patch to solve my problem.
In general, I would prefer to use control interface for more or less all
uses except for some detailed debugging. In other words, is something is
missing from the output available from control interface, the proper fix
would be to convert the wpa_printf() to wpa_msg()..
--
Jouni Malinen PGP id EFC895FA
More information about the Hostap
mailing list