1.0.8.16: refactored fd-stream buffering
commit34652b637f023fb24cf76df53e6a1936e94ce9ec
authorNikodemus Siivola <nikodemus@random-state.net>
Mon, 6 Aug 2007 11:50:46 +0000 (6 11:50 +0000)
committerNikodemus Siivola <nikodemus@random-state.net>
Mon, 6 Aug 2007 11:50:46 +0000 (6 11:50 +0000)
treec40398d4cc499075f74a37db07b6aab3af116158
parentef716ee5409d0d55020aea422e29a9175c2b4b74
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.
NEWS
contrib/sb-simple-streams/internal.lisp
contrib/sb-simple-streams/terminal.lisp
src/code/fd-stream.lisp
src/code/stream.lisp
src/code/thread.lisp
src/compiler/target-dump.lisp
tests/external-format.impure.lisp
tests/stream.impure.lisp
tests/stream.pure.lisp
version.lisp-expr