Skip to content

Commit

Permalink
[CLISP] fix for clisp server sockets (usocket#28) (patch from vibs29)
Browse files Browse the repository at this point in the history
* fix wait-for-input for clisp

cl-mongo was unable to make database queries when running in clisp. I tracked the problem down to this one line. Changing it as shown fixed things for me.

* fixed server sockets, which my previous fix for client sockets broke
  • Loading branch information
vibs29 authored and binghe committed Apr 16, 2017
1 parent 2f30276 commit 5356978
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions backend/clisp.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,14 @@
(declare (ignore wait-list)))

(defun %add-waiter (wait-list waiter)
(push (cons (socket waiter) NIL) (wait-list-%wait wait-list)))
;; clisp's #'socket-status takes a list whose elts look either like,
;; (socket-stream direction . x) or like,
;; (socket-server . x)
;; and it replaces the x's.
(push (cons (socket waiter)
(cond ((stream-usocket-p waiter) (cons NIL NIL))
(t NIL)))
(wait-list-%wait wait-list)))

(defun %remove-waiter (wait-list waiter)
(setf (wait-list-%wait wait-list)
Expand All @@ -243,16 +250,17 @@
(secs musecs)
(split-timeout (or timeout 1))
(dolist (x (wait-list-%wait wait-list))
(setf (cdr x) :INPUT))
(when (consp (cdr x)) ;it's a socket-stream not socket-server
(setf (cadr x) :INPUT)))
(let* ((request-list (wait-list-%wait wait-list))
(status-list (if timeout
(socket:socket-status request-list secs musecs)
(socket:socket-status request-list)))
(sockets (wait-list-waiters wait-list)))
(do* ((x (pop sockets) (pop sockets))
(y (pop status-list) (pop status-list)))
(y (cdr (last (pop status-list))) (cdr (last (pop status-list)))))
((null x))
(when (member y '(T :INPUT))
(when (member y '(T :INPUT :EOF))
(setf (state x) :READ)))
wait-list))))

Expand Down

0 comments on commit 5356978

Please sign in to comment.