os: Restore buffer when writing to network
The commit 9bf46610 "os: Immediately queue initial WriteToClient" effectively disables buffering (of all writes, not just the "initial" write), since the OS's network buffers will usually be large enough to hold whatever replies we have sent.
This does improve performance when drawing over a Unix socket (I measure approximtely 10%, not the ~5x mentioned in that commit message, probably due to the large changes in this area since that commit), but it decreases performance when drawing over a network due to the additional TCP packets. This decrease is small (~10%) in most cases, but if the two machines have mismatched Nagle / tcp_delay settings it can cause XGetWindowAttributes to take 200ms (because it's composed of two requests, the 2nd of which might wait for the ack which is delayed).
Avoid network slowdowns by making the immediate flush conditional on who->local.
Signed-off-by: Peter Harris pharris@opentext.com