1.0.8.16: refactored fd-stream buffering
Thanks to David Smith and Andreas Bogkt who diagnosed the memory
leaks this patch fixes.
* Instead of having FD-STREAM objects directly hold onto input and
output buffer SAPs and head/tail indexes, use BUFFER objects which
contain the SAP, size of the memory area, head/tail indexes, and
are have finalizers to deallocate the system memory assosicated
with the SAP. (This fixes system memory leaks when streams are not
properly closed.)
* Make CLOSE :ABORT release the output queue associated with the
stream. (This was another memory leak in the old system: now
the finalizers make not doing this safe, but it's still better
to recycle the buffers.)
* Slightly reduce lock contention by grabbing the *AVAILABLE-BUFFERS*
lock only if there is something there right before the lock is
taken, and by doing allocation outside the lock.
* Rename and refactor FROB-OUTPUT and friends:
BUFFER-OUTPUT is the main interface function, which always
adds new output to the current buffer / output queue.
WRITE-OR-BUFFER-OUTPUT tries to write immediately, falling
back to buffering if writing is not possible.
WRITE-OUTPUT-FROM-QUEUE is called by the SERVE-EVENT
system to deal with output queue.
FLUSH-OUTPUT-BUFFER writes the current buffer out if possible,
queues it otherwise. Ensures that the output buffer of
the stream is empty on return (and returns that buffer).
* Deprecate SB-SYS:OUTPUT-RAW-BYTES. There doesn't seem to be any
real reason to export this kind of stuff.
* Increment the fasl version.