[usocket-devel] SBCL data flush problem
Robert Brown
robert.brown at gmail.com
Wed Aug 3 21:58:07 UTC 2011
I use SBCL on Linux and have noticed a problem when writing
lots of data to socket streams created with usocket.
In file backend/sbcl.lisp, the function socket-connect creates a
stream as follows:
(setf (socket-stream usocket)
(sb-bsd-sockets:socket-make-stream socket
:input t
:output t
:buffering :full
:element-type element-type))
If you look at the code for sb-bsd-sockets:socket-make-stream in
sbcl/contrib/sb-bsd-sockets/sockets.lisp, you'll see that it specifies
a default value of T for the keyword argument serve-events:
(defmethod socket-make-stream ((socket socket)
&key input output
(element-type 'character)
(buffering :full)
(external-format :default)
timeout
auto-close
(serve-events t))
This means that SBCL streams created by usocket have a true
serve-events property. When writing large amounts of data to several
streams, the kernel will eventually stop accepting data from SBCL.
When this happens, SBCL either waits for I/O to be possible on
the file descriptor it's writing to or queues the data to be flushed later.
Because usocket streams specify serve-events as true, SBCL
always queues. Instead, it should wait for I/O to be available and
write the remaining data to the socket. That's what serve-events
equal to NIL gets you.
Usocket should add
:serve-events NIL
to the call to socket-make-stream.
bob
More information about the usocket-devel
mailing list