|
@@ -146,7 +146,7 @@ int ws_handle_handshake(struct sip_msg *msg)
|
|
if (con->type != PROTO_TCP && con->type != PROTO_TLS)
|
|
if (con->type != PROTO_TCP && con->type != PROTO_TLS)
|
|
{
|
|
{
|
|
LM_ERR("unsupported transport: %d", con->type);
|
|
LM_ERR("unsupported transport: %d", con->type);
|
|
- return 0;
|
|
|
|
|
|
+ goto end;
|
|
}
|
|
}
|
|
|
|
|
|
if (parse_headers(msg, HDR_EOH_F, 0) < 0)
|
|
if (parse_headers(msg, HDR_EOH_F, 0) < 0)
|
|
@@ -154,7 +154,7 @@ int ws_handle_handshake(struct sip_msg *msg)
|
|
LM_ERR("error parsing headers\n");
|
|
LM_ERR("error parsing headers\n");
|
|
ws_send_reply(msg, 500, &str_status_internal_server_error,
|
|
ws_send_reply(msg, 500, &str_status_internal_server_error,
|
|
NULL);
|
|
NULL);
|
|
- return 0;
|
|
|
|
|
|
+ goto end;
|
|
}
|
|
}
|
|
|
|
|
|
/* Process HTTP headers */
|
|
/* Process HTTP headers */
|
|
@@ -201,7 +201,7 @@ int ws_handle_handshake(struct sip_msg *msg)
|
|
ws_send_reply(msg, 400,
|
|
ws_send_reply(msg, 400,
|
|
&str_status_bad_request,
|
|
&str_status_bad_request,
|
|
NULL);
|
|
NULL);
|
|
- return 0;
|
|
|
|
|
|
+ goto end;
|
|
}
|
|
}
|
|
|
|
|
|
LM_DBG("found %.*s: %.*s\n",
|
|
LM_DBG("found %.*s: %.*s\n",
|
|
@@ -245,7 +245,7 @@ int ws_handle_handshake(struct sip_msg *msg)
|
|
ws_send_reply(msg, 400,
|
|
ws_send_reply(msg, 400,
|
|
&str_status_bad_request,
|
|
&str_status_bad_request,
|
|
NULL);
|
|
NULL);
|
|
- return 0;
|
|
|
|
|
|
+ goto end;
|
|
}
|
|
}
|
|
|
|
|
|
str2sint(&hdr->body, &version);
|
|
str2sint(&hdr->body, &version);
|
|
@@ -263,7 +263,7 @@ int ws_handle_handshake(struct sip_msg *msg)
|
|
ws_send_reply(msg, 426,
|
|
ws_send_reply(msg, 426,
|
|
&str_status_upgrade_required,
|
|
&str_status_upgrade_required,
|
|
&headers);
|
|
&headers);
|
|
- return 0;
|
|
|
|
|
|
+ goto end;
|
|
}
|
|
}
|
|
|
|
|
|
LM_DBG("found %.*s: %.*s\n",
|
|
LM_DBG("found %.*s: %.*s\n",
|
|
@@ -308,7 +308,7 @@ int ws_handle_handshake(struct sip_msg *msg)
|
|
str_hdr_sec_websocket_version.s,
|
|
str_hdr_sec_websocket_version.s,
|
|
WS_VERSION);
|
|
WS_VERSION);
|
|
ws_send_reply(msg, 400, &str_status_bad_request, &headers);
|
|
ws_send_reply(msg, 400, &str_status_bad_request, &headers);
|
|
- return 0;
|
|
|
|
|
|
+ goto end;
|
|
}
|
|
}
|
|
|
|
|
|
/* Construct reply_key */
|
|
/* Construct reply_key */
|
|
@@ -319,7 +319,7 @@ int ws_handle_handshake(struct sip_msg *msg)
|
|
LM_ERR("allocating pkg memory\n");
|
|
LM_ERR("allocating pkg memory\n");
|
|
ws_send_reply(msg, 500, &str_status_internal_server_error,
|
|
ws_send_reply(msg, 500, &str_status_internal_server_error,
|
|
NULL);
|
|
NULL);
|
|
- return 0;
|
|
|
|
|
|
+ goto end;
|
|
}
|
|
}
|
|
memcpy(reply_key.s, key.s, key.len);
|
|
memcpy(reply_key.s, key.s, key.len);
|
|
memcpy(reply_key.s + key.len, str_ws_guid.s, str_ws_guid.len);
|
|
memcpy(reply_key.s + key.len, str_ws_guid.s, str_ws_guid.len);
|
|
@@ -380,10 +380,15 @@ int ws_handle_handshake(struct sip_msg *msg)
|
|
if ((wsc = wsconn_get(msg->rcv.proto_reserved1)) != NULL)
|
|
if ((wsc = wsconn_get(msg->rcv.proto_reserved1)) != NULL)
|
|
wsconn_rm(wsc, WSCONN_EVENTROUTE_NO);
|
|
wsconn_rm(wsc, WSCONN_EVENTROUTE_NO);
|
|
|
|
|
|
- return 0;
|
|
|
|
|
|
+ goto end;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ tcpconn_put(con);
|
|
return 1;
|
|
return 1;
|
|
|
|
+end:
|
|
|
|
+ if (con)
|
|
|
|
+ tcpconn_put(con);
|
|
|
|
+ return 0;
|
|
}
|
|
}
|
|
|
|
|
|
struct mi_root *ws_mi_disable(struct mi_root *cmd, void *param)
|
|
struct mi_root *ws_mi_disable(struct mi_root *cmd, void *param)
|