[svn-commits] kharwell: branch 13 r431670 - in /branches/13: ./ res/ res/ari/
SVN commits to the Digium repositories
svn-commits at lists.digium.com
Wed Feb 11 10:51:33 CST 2015
Author: kharwell
Date: Wed Feb 11 10:51:29 2015
New Revision: 431670
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=431670
Log:
res_http_websocket: websocket write timeout fails to fully disconnect
When writing to a websocket if a timeout occurred the underlying socket did not
get closed/disconnected. This patch makes sure the websocket gets disconnected
on a write timeout. Also a notice is logged stating that the websocket was
disconnected.
ASTERISK-24701 #close
Reported by: Matt Jordan
Review: https://reviewboard.asterisk.org/r/4412/
........
Merged revisions 431669 from http://svn.asterisk.org/svn/asterisk/branches/11
Modified:
branches/13/ (props changed)
branches/13/res/ari/ari_websockets.c
branches/13/res/res_http_websocket.c
Propchange: branches/13/
------------------------------------------------------------------------------
--- branch-11-merged (original)
+++ branch-11-merged Wed Feb 11 10:51:29 2015
@@ -1,1 +1,1 @@
-/branches/11:1-429517,429539,429632,429783,429804,429825,429867,429893,429982,430009,430126,430415,430487,430506,430564,430589,430795,430798,430920,430993,430996-430997,431049,431135,431187,431218,431384,431423,431617,431662
+/branches/11:1-429517,429539,429632,429783,429804,429825,429867,429893,429982,430009,430126,430415,430487,430506,430564,430589,430795,430798,430920,430993,430996-430997,431049,431135,431187,431218,431384,431423,431617,431662,431669
Modified: branches/13/res/ari/ari_websockets.c
URL: http://svnview.digium.com/svn/asterisk/branches/13/res/ari/ari_websockets.c?view=diff&rev=431670&r1=431669&r2=431670
==============================================================================
--- branches/13/res/ari/ari_websockets.c (original)
+++ branches/13/res/ari/ari_websockets.c Wed Feb 11 10:51:29 2015
@@ -99,6 +99,16 @@
struct ast_ari_websocket_session *session)
{
RAII_VAR(struct ast_json *, message, NULL, ast_json_unref);
+
+ if (ast_websocket_fd(session->ws_session) < 0) {
+ return NULL;
+ }
+
+
+ if (ast_websocket_fd(session->ws_session) <= 0) {
+ return NULL;
+ }
+
while (!message) {
int res;
@@ -127,7 +137,7 @@
switch (opcode) {
case AST_WEBSOCKET_OPCODE_CLOSE:
- ast_debug(1, "WebSocket closed by peer\n");
+ ast_debug(1, "WebSocket closed\n");
return NULL;
case AST_WEBSOCKET_OPCODE_TEXT:
message = ast_json_load_buf(payload, payload_len, NULL);
@@ -173,8 +183,12 @@
}
ast_debug(3, "Examining ARI event: \n%s\n", str);
- return ast_websocket_write(session->ws_session,
- AST_WEBSOCKET_OPCODE_TEXT, str, strlen(str));
+ if (ast_websocket_write(session->ws_session,
+ AST_WEBSOCKET_OPCODE_TEXT, str, strlen(str))) {
+ ast_log(LOG_NOTICE, "Problem occurred during websocket write, websocket closed\n");
+ return -1;
+ }
+ return 0;
}
void ari_handle_websocket(struct ast_websocket_server *ws_server,
Modified: branches/13/res/res_http_websocket.c
URL: http://svnview.digium.com/svn/asterisk/branches/13/res/res_http_websocket.c?view=diff&rev=431670&r1=431669&r2=431670
==============================================================================
--- branches/13/res/res_http_websocket.c (original)
+++ branches/13/res/res_http_websocket.c Wed Feb 11 10:51:29 2015
@@ -307,11 +307,15 @@
}
if (ast_careful_fwrite(session->f, session->fd, frame, header_size, session->timeout)) {
ao2_unlock(session);
+ /* 1011 - server terminating connection due to not being able to fulfill the request */
+ ast_websocket_close(session, 1011);
return -1;
}
if (ast_careful_fwrite(session->f, session->fd, payload, actual_length, session->timeout)) {
ao2_unlock(session);
+ /* 1011 - server terminating connection due to not being able to fulfill the request */
+ ast_websocket_close(session, 1011);
return -1;
}
fflush(session->f);
More information about the svn-commits
mailing list