From 724354ff470f264a2cb6cd849d444fd99dcbb5f4 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Mon, 26 Oct 2015 14:34:54 +0530 Subject: [PATCH] Fix extra close frame being sent during shutdown --- src/calibre/srv/web_socket.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/calibre/srv/web_socket.py b/src/calibre/srv/web_socket.py index ae9e15646e..09451f7791 100644 --- a/src/calibre/srv/web_socket.py +++ b/src/calibre/srv/web_socket.py @@ -414,7 +414,7 @@ class WebSocketConnection(HTTPConnection): self.log.exception('Error in WebSocket close handler') # Try to write a close frame, just once 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') with self.cf_lock: self.write(self.control_frames.pop())