]> git.ipfire.org Git - thirdparty/asterisk.git/commit
res_http_websocket.c: prevent avoidable disconnections caused by write errors 66/1866/2
authorDade Brandon <dade@xencall.com>
Fri, 25 Dec 2015 04:19:59 +0000 (20:19 -0800)
committerDade Brandon <dade@xencall.com>
Mon, 28 Dec 2015 19:38:32 +0000 (11:38 -0800)
commit136c537695224b6edbb9ab8550dc33cf6b29eb83
treef3c1aee50fb78bebf29fcba0720b6df1c2720706
parent1e24a0ca8ae075af2814668fc99ecfabb47423b3
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
include/asterisk/http_websocket.h
res/res_http_websocket.c