[asterisk-commits] res http websocket: When shutting down a session don't close... (asterisk[13])

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Thu Aug 13 11:26:02 CDT 2015


Joshua Colp has submitted this change and it was merged.

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


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

Approvals:
  Kevin Harwell: Looks good to me, but someone else must approve
  Anonymous Coward #1000019: Verified
  Joshua Colp: Looks good to me, approved



diff --git a/res/res_http_websocket.c b/res/res_http_websocket.c
index ea3e959..c2d1b18 100644
--- a/res/res_http_websocket.c
+++ b/res/res_http_websocket.c
@@ -167,9 +167,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/1078
To unsubscribe, visit https://gerrit.asterisk.org/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I7572583529a42a7dc911ea77a974d8307d5c0c8b
Gerrit-PatchSet: 2
Gerrit-Project: asterisk
Gerrit-Branch: 13
Gerrit-Owner: Joshua Colp <jcolp at digium.com>
Gerrit-Reviewer: Anonymous Coward #1000019
Gerrit-Reviewer: Joshua Colp <jcolp at digium.com>
Gerrit-Reviewer: Kevin Harwell <kharwell at digium.com>



More information about the asterisk-commits mailing list