Permalink
Browse files

avoid race condition with client-connected message

previously protocol 7/8/13 handler sent :connect message to resource
handler before version was set inclient object, so data sent by
connect handler could be lost
  • Loading branch information...
1 parent b7f9e5e commit a956bd5242c564e862d24e67a0699a0378240307 @3b committed Apr 10, 2012
Showing with 7 additions and 3 deletions.
  1. +7 −3 protocol-7.lisp
View
@@ -77,9 +77,7 @@ Sec-WebSocket-Accept: ~a
"
(make-challenge-o7 key))
- :encoding :iso-8859-1))
- (setf (client-connection-state client) :connected)
- (client-enqueue-read client (list client :connect))))
+ :encoding :iso-8859-1))))
t)))
@@ -282,16 +280,22 @@ Sec-WebSocket-Accept: ~a
(defun protocol-7-parse-headers (client)
(when (protocol-7+-handshake client "7" :sec-websocket-origin)
(setf (client-websocket-version client) 7)
+ (setf (client-connection-state client) :connected)
+ (client-enqueue-read client (list client :connect))
(protocol-7+-start-frame client)))
(defun protocol-8-parse-headers (client)
(when (protocol-7+-handshake client "8" :sec-websocket-origin)
(setf (client-websocket-version client) 8)
+ (setf (client-connection-state client) :connected)
+ (client-enqueue-read client (list client :connect))
(protocol-7+-start-frame client)))
(defun protocol-13-parse-headers (client)
(when (protocol-7+-handshake client "13" :origin)
(setf (client-websocket-version client) 8)
+ (setf (client-connection-state client) :connected)
+ (client-enqueue-read client (list client :connect))
(protocol-7+-start-frame client)))
(setf (gethash "7" *protocol-header-parsers*) 'protocol-7-parse-headers

0 comments on commit a956bd5

Please sign in to comment.