[Asterisk-code-review] res http websocket.c: prevent avoidable disconnections cause... (asterisk[11])

Dade Brandon asteriskteam at digium.com
Mon Dec 28 13:33:48 CST 2015


Hello Anonymous Coward #1000019, Matt Jordan,

I'd like you to reexamine a change.  Please visit

    https://gerrit.asterisk.org/1863

to look at the new patch set (#2).

Change subject: res_http_websocket.c: prevent avoidable disconnections caused by write errors
......................................................................

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
---
M include/asterisk/http_websocket.h
M res/res_http_websocket.c
2 files changed, 17 insertions(+), 17 deletions(-)


  git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/63/1863/2
-- 
To view, visit https://gerrit.asterisk.org/1863
To unsubscribe, visit https://gerrit.asterisk.org/settings

Gerrit-MessageType: newpatchset
Gerrit-Change-Id: I4db7a586af1c7a57184c31d3d55bf146f1a40598
Gerrit-PatchSet: 2
Gerrit-Project: asterisk
Gerrit-Branch: 11
Gerrit-Owner: Dade Brandon <dade at xencall.com>
Gerrit-Reviewer: Anonymous Coward #1000019
Gerrit-Reviewer: Dade Brandon <dade at xencall.com>
Gerrit-Reviewer: Joshua Colp <jcolp at digium.com>
Gerrit-Reviewer: Matt Jordan <mjordan at digium.com>



More information about the asterisk-code-review mailing list