summaryrefslogtreecommitdiff
path: root/res/res_http_websocket.c
diff options
context:
space:
mode:
authorJoshua Colp <jcolp@digium.com>2015-08-13 07:26:51 -0300
committerJoshua Colp <jcolp@digium.com>2015-08-13 05:36:32 -0500
commit495dfb24b732bf74b85119c0a081bff83d06a3f1 (patch)
tree319a35481331ab628f927e3e400f3b911a1a215c /res/res_http_websocket.c
parente1e37e47fd011398b406efe4d4b1630b8d537859 (diff)
res_http_websocket: When shutting down a session don't close closed socket
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
Diffstat (limited to 'res/res_http_websocket.c')
-rw-r--r--res/res_http_websocket.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/res/res_http_websocket.c b/res/res_http_websocket.c
index 956ed0a51..a29daa8ff 100644
--- a/res/res_http_websocket.c
+++ b/res/res_http_websocket.c
@@ -169,9 +169,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);