]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
res_http_websocket: When shutting down a session don't close closed socket 80/1080/2
authorJoshua Colp <jcolp@digium.com>
Thu, 13 Aug 2015 10:26:51 +0000 (07:26 -0300)
committerJoshua Colp <jcolp@digium.com>
Thu, 13 Aug 2015 10:36:16 +0000 (05:36 -0500)
Due to the use of ast_websocket_close in session termination it is
possible for the underlying socket to already be closed when the
session is terminated. This occurs when the close frame is attempted
to be written out but fails.

Change-Id: I7572583529a42a7dc911ea77a974d8307d5c0c8b

res/res_http_websocket.c

index 8319579d589e8fb3e8746d5cdd1ed90f75c4c56e..4731f25951d49a8076a6828f5ee22b6596147385 100644 (file)
@@ -173,9 +173,11 @@ static void session_destroy_fn(void *obj)
 
        if (session->f) {
                ast_websocket_close(session, 0);
-               fclose(session->f);
-               ast_verb(2, "WebSocket connection %s '%s' closed\n", session->client ? "to" : "from",
-                       ast_sockaddr_stringify(&session->address));
+               if (session->f) {
+                       fclose(session->f);
+                       ast_verb(2, "WebSocket connection %s '%s' closed\n", session->client ? "to" : "from",
+                               ast_sockaddr_stringify(&session->address));
+               }
        }
 
        ao2_cleanup(session->client);