summaryrefslogtreecommitdiff
path: root/include/asterisk/http_websocket.h
diff options
context:
space:
mode:
authorDade Brandon <dade@xencall.com>2015-12-24 20:19:59 -0800
committerDade Brandon <dade@xencall.com>2015-12-28 11:41:41 -0800
commit3bddcc0219bbe18ae925e1d41301fa9001530804 (patch)
tree299c2a744136d2aee1c15f81a82986972c2d9e59 /include/asterisk/http_websocket.h
parentb4b4a95225a6170c4ddd0e567218d4033d9600f8 (diff)
res_http_websocket.c: prevent avoidable disconnections caused by write errors
Updated ast_websocket_write to encode the entire frame in to one write operation, to ensure that we don't end up with a situation where the websocket header has been sent, while the body can not be written. Previous to August's patch in commit b9bd3c14, certain network conditions could cause the header to be written, and then the sub-sequent body to fail - which would cause the next successful write to contain a new header, and a new body (resulting in the peer receiving two headers - the second of which would be read as part of the body for the first header). This was patched to have both write operations individually fail by closing the websocket. In a case available to the submitter of this patch, the same body which would consistently fail to write, would succeed if written at the same time as the header. This update merges the two operations in to one, adds debug messages indicating the reason for a websocket connection being closed during a write operation, and clarifies some variable names for code legibility. Change-Id: I4db7a586af1c7a57184c31d3d55bf146f1a40598
Diffstat (limited to 'include/asterisk/http_websocket.h')
-rw-r--r--include/asterisk/http_websocket.h4
1 files changed, 2 insertions, 2 deletions
diff --git a/include/asterisk/http_websocket.h b/include/asterisk/http_websocket.h
index 23492ff95..cd49dbe48 100644
--- a/include/asterisk/http_websocket.h
+++ b/include/asterisk/http_websocket.h
@@ -266,12 +266,12 @@ AST_OPTIONAL_API(int, ast_websocket_read_string,
* \param session Pointer to the WebSocket session
* \param opcode WebSocket operation code to place in the frame
* \param payload Optional pointer to a payload to add to the frame
- * \param actual_length Length of the payload (0 if no payload)
+ * \param payload_size Length of the payload (0 if no payload)
*
* \retval 0 if successfully written
* \retval -1 if error occurred
*/
-AST_OPTIONAL_API(int, ast_websocket_write, (struct ast_websocket *session, enum ast_websocket_opcode opcode, char *payload, uint64_t actual_length), { errno = ENOSYS; return -1;});
+AST_OPTIONAL_API(int, ast_websocket_write, (struct ast_websocket *session, enum ast_websocket_opcode opcode, char *payload, uint64_t payload_size), { errno = ENOSYS; return -1;});
/*!
* \brief Construct and transmit a WebSocket frame containing string data.