From: Joshua Colp Date: Thu, 13 Aug 2015 10:26:51 +0000 (-0300) Subject: res_http_websocket: When shutting down a session don't close closed socket X-Git-Tag: 13.6.0-rc1~86 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e18c300550453df06507e32c4bc78ef91d369f27;p=thirdparty%2Fasterisk.git 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 --- diff --git a/res/res_http_websocket.c b/res/res_http_websocket.c index ea3e959d94..c2d1b18506 100644 --- a/res/res_http_websocket.c +++ b/res/res_http_websocket.c @@ -167,9 +167,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);