[Asterisk-code-review] res http websocket: When shutting down a session don't close... (asterisk[certified/13.1])

Joshua Colp asteriskteam at digium.com
Thu Aug 13 05:33:26 CDT 2015


Joshua Colp has uploaded a new change for review.

  https://gerrit.asterisk.org/1080

Change subject: res_http_websocket: When shutting down a session don't close socket closed
......................................................................

res_http_websocket: When shutting down a session don't close socket closed

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
---
M res/res_http_websocket.c
1 file changed, 5 insertions(+), 3 deletions(-)


  git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/80/1080/1

diff --git a/res/res_http_websocket.c b/res/res_http_websocket.c
index 8319579..4731f25 100644
--- a/res/res_http_websocket.c
+++ b/res/res_http_websocket.c
@@ -173,9 +173,11 @@
 
 	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);

-- 
To view, visit https://gerrit.asterisk.org/1080
To unsubscribe, visit https://gerrit.asterisk.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I7572583529a42a7dc911ea77a974d8307d5c0c8b
Gerrit-PatchSet: 1
Gerrit-Project: asterisk
Gerrit-Branch: certified/13.1
Gerrit-Owner: Joshua Colp <jcolp at digium.com>



More information about the asterisk-code-review mailing list