From 535697849da1c79de7055d183b02a52f8fad4079 Mon Sep 17 00:00:00 2001 From: vibs29 Date: Sun, 16 Apr 2017 09:11:20 +0100 Subject: [PATCH] [CLISP] fix for clisp server sockets (#28) (patch from vibs29) * 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 --- backend/clisp.lisp | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/backend/clisp.lisp b/backend/clisp.lisp index 63ea9d6..62d3af5 100644 --- a/backend/clisp.lisp +++ b/backend/clisp.lisp @@ -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) @@ -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))))