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

Joshua Colp asteriskteam at digium.com
Thu Aug 13 11:26:07 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 956ed0a..a29daa8 100644
--- a/res/res_http_websocket.c
+++ b/res/res_http_websocket.c
@@ -169,9 +169,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/1079
To unsubscribe, visit https://gerrit.asterisk.org/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I7572583529a42a7dc911ea77a974d8307d5c0c8b
Gerrit-PatchSet: 2
Gerrit-Project: asterisk
Gerrit-Branch: master
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-code-review mailing list