Fix extra close frame being sent during shutdown

This commit is contained in:
Kovid Goyal 2015-10-26 14:34:54 +05:30
parent 9e4e8985f0
commit 724354ff47

View File

@ -414,7 +414,7 @@ class WebSocketConnection(HTTPConnection):
self.log.exception('Error in WebSocket close handler') self.log.exception('Error in WebSocket close handler')
# Try to write a close frame, just once # Try to write a close frame, just once
try: try:
if self.send_buf is None: if self.send_buf is None and not self.ws_close_sent:
self.websocket_close(SHUTTING_DOWN, 'Shutting down') self.websocket_close(SHUTTING_DOWN, 'Shutting down')
with self.cf_lock: with self.cf_lock:
self.write(self.control_frames.pop()) self.write(self.control_frames.pop())