diff --git a/contrib/serve-event/serve-event.lisp b/contrib/serve-event/serve-event.lisp index 895738772..986c1cba2 100644 --- a/contrib/serve-event/serve-event.lisp +++ b/contrib/serve-event/serve-event.lisp @@ -56,11 +56,20 @@ (define-c-constants +eintr+ "EINTR") +(defmethod ext::stream-fd ((stream t)) + (etypecase stream + (fixnum stream) + (two-way-stream (ext::stream-fd (two-way-stream-input-stream stream))) + (file-stream (si:file-stream-fd stream)) + (otherwise (error "In SERVE-EVENT, stream~% ~A~%does not have an associated file descriptor" stream)))) + (defstruct (handler - (:constructor make-handler (direction descriptor function)) + (:constructor make-handler (direction stream-or-descriptor function + &aux (descriptor (ext::stream-fd stream-or-descriptor)))) (:copier nil)) ;; Reading or writing... (direction nil :type (member :input :output)) + (stream-or-descriptor nil) ;; File descriptor this handler is tied to. ;; FIXME: Should be based on FD_SETSIZE (descriptor 0) diff --git a/contrib/sockets/sockets.lisp b/contrib/sockets/sockets.lisp index b60aa9564..41743f71f 100755 --- a/contrib/sockets/sockets.lisp +++ b/contrib/sockets/sockets.lisp @@ -1236,6 +1236,9 @@ also known as unix-domain sockets.")) (sb-ext:cancel-finalization socket)) stream)) +(defmethod ext::stream-fd ((socket socket)) + (socket-file-descriptor socket)) + #+:wsock (defmethod socket-make-stream ((socket named-pipe-socket) &key input output