Module: sip-router
Branch: master
Commit: 438eafc92ecf9d3b52f95c9952bc26b147fdf328
URL:
http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=438eafc…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: Mon Jan 6 23:11:33 2014 +0100
websocket: store sub protocol value for later use in encode_and_send_ws_frame()
- the ws connection pointer can be set null if the browser closes the
connection
- patch by Vitaliy Aleksandrov, FS#364
---
modules/websocket/ws_frame.c | 7 +++++--
1 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/modules/websocket/ws_frame.c b/modules/websocket/ws_frame.c
index 3ccb4d1..ba0713b 100644
--- a/modules/websocket/ws_frame.c
+++ b/modules/websocket/ws_frame.c
@@ -141,6 +141,7 @@ static int encode_and_send_ws_frame(ws_frame_t *frame, conn_close_t
conn_close)
struct dest_info dst;
union sockaddr_union *from = NULL;
union sockaddr_union local_addr;
+ int sub_proto;
LM_DBG("encoding WebSocket frame\n");
@@ -166,6 +167,8 @@ static int encode_and_send_ws_frame(ws_frame_t *frame, conn_close_t
conn_close)
return -1;
}
+ sub_proto = frame->wsc->sub_protocol;
+
switch(frame->opcode)
{
case OPCODE_TEXT_FRAME:
@@ -299,9 +302,9 @@ static int encode_and_send_ws_frame(ws_frame_t *frame, conn_close_t
conn_close)
LM_ERR("sending WebSocket frame\n");
pkg_free(send_buf);
update_stat(ws_failed_connections, 1);
- if (frame->wsc->sub_protocol == SUB_PROTOCOL_SIP)
+ if (sub_proto == SUB_PROTOCOL_SIP)
update_stat(ws_sip_failed_connections, 1);
- else if (frame->wsc->sub_protocol == SUB_PROTOCOL_MSRP)
+ else if (sub_proto == SUB_PROTOCOL_MSRP)
update_stat(ws_msrp_failed_connections, 1);
if (wsconn_rm(frame->wsc, WSCONN_EVENTROUTE_YES) < 0)
LM_ERR("removing WebSocket connection\n");