[Ecls-list] Problems with slime

Tobias C. Rittweiler tcr at freebits.de
Tue Feb 9 22:18:52 UTC 2010


Ram Krishnan writes:

> Tobias,
>
> I ran into this issue on MacOSX, and it turned out to be because SLIME
> has multiple threads (control and reader threads) which want to read
> and write the connection socket stream. The issue (on MacOSX atleast)
> was that the standard buffered I/O library (which handles the FILE*
> data structure and functions), has been made thread safe, and locks
> the file stream when any thread uses it. The tragedy is that there
> seems to be only one lock, for both read and write, which means if one
> thread locks the stream to read then another thread cannot do anything
> with it, not even write. Anyway, the hack I came up with was to modify
> the swank-ecl backend to return a two-way-stream with two independent
> file-streams for the two directions:
>
> (defun socket-make-stream (socket &rest args)
>   (let ((stream (apply 'sb-bsd-sockets:socket-make-stream socket args)))
>     (setf (slot-value socket 'sb-bsd-sockets::stream) nil)
>     stream))
>
> (defun make-socket-io-stream (socket)
>   (case (preferred-communication-style)
>     (:fd-handler
>      (sb-bsd-sockets:socket-make-stream socket
>                                         :output t
>                                         :input t
>                                         :element-type 'base-char))
>     (:spawn
>      (let* ((input (socket-make-stream socket
>                                        :direction :input
>                                        :element-type 'base-char))
>             (output (socket-make-stream socket
>                                         :direction :output
>                                         :element-type 'base-char))
>             (stream (make-two-way-stream input output)))
>        (setf (slot-value socket 'sb-bsd-sockets::stream) stream)
>        stream))))
>
> Admittedly this hack is ugly, as it knows way too much about what the
> underlying socket implementation is doing. The right place to fix this
> is probably in SOCKETS::SOCKET-MAKE-STREAM, based on a DIRECTION
> keyword arg or something.

Hi Ram,

thanks for commenting. I saw your patch earlier, and I actually
copy&pasted the above implementation of MAKE-SOCKET-IO-STREAM into my
swank-ecl.lisp to see whether it makes a difference, but it does _not_.

I'm on Ubuntu 9.10, FWIW.

How did you find out about the locking?


> Here's a link to the complete set of patches:
>
>   http://github.com/kriyative/ecl-iphone-builder/blob/master/swank-ecl-patches.txt
>
> Anyway, hope this is useful in your efforts.

Thanks, I'll try to get the :FD-HANDLER communication style into the
official swank-ecl when I find time. Why did you change AUTO-FLUSH-LOOP?

  -T.





More information about the ecl-devel mailing list