Libxo bugs and fixes.

Alfred Perlstein bright at mu.org
Sun Dec 28 03:07:33 UTC 2014


On 12/25/14 2:23 PM, Simon J. Gerraty wrote:
> Alfred Perlstein <bright at mu.org> wrote:
>> I don't think my patch adds an xo_flush to xo_emit...  ?
> No, you added a test around it - I only looked at the RHS.
>
OK, so I've updated https://reviews.freebsd.org/D1379 to include code to 
handle this.

Solaris and glibc have a private libc function to check if a stream is 
line buffered called int __flbf (FILE *stream) which returns true/false 
if the stream if line buffered or not.

We can use this in libxo now.

This should avoid the superfluous flushes.

One other topic, I talked to some webdevs and they suggested that we 
have a "jsonLD" which stands for "json line delimited" that would be 
useful for periodic output.  This would be halfway between a "pretty 
format" and a compact stream format.  meaning that each line would be a 
record, example:

Currently:
/usr/src/contrib/libxo/libxo % netstat --libxo json,pretty 1
{
   "statistics": {
     "interface-statistics": [
       {
         "received-packets": 2,
         "received-errors": 0,
         "dropped-packets": 0,
         "received-bytes": 132,
         "sent-packets": 4,
         "send-errors": 0,
         "sent-bytes": 1080,
         "collisions": 0
       },
       {
         "received-packets": 2,
         "received-errors": 0,
         "dropped-packets": 0,
         "received-bytes": 132,
         "sent-packets": 6,
         "send-errors": 0,
         "sent-bytes": 1964,
         "collisions": 0
       },
       {
         "received-packets": 1,
         "received-errors": 0,
         "dropped-packets": 0,
         "received-bytes": 66,
         "sent-packets": 4,
         "send-errors": 0,
         "sent-bytes": 1048,
         "collisions": 0


Later we might want to support something like this:
/usr/src/contrib/libxo/libxo % netstat --libxo json,ld 1
{
   "statistics": {
     "interface-statistics": [
       {        "received-packets": 2,        "received-errors": 
0,        "dropped-packets": 0,        "received-bytes": 132, 
"sent-packets": 4,        "send-errors": 0,        "sent-bytes": 
1080,        "collisions": 0      },
       { "received-packets": 2, "received-errors": 0, "dropped-packets": 
0,        "received-bytes": 132, "sent-packets": 6,        
"send-errors": 0,        "sent-bytes": 1964,        "collisions": 0      },
       {        "received-packets": 1,        "received-errors": 
0,        "dropped-packets": 0,        "received-bytes": 66, 
"sent-packets": 4,        "send-errors": 0,        "sent-bytes": 
1048,        "collisions": 0 }

Let me know what you think.

-Alfred



More information about the freebsd-arch mailing list