websocket: Consider pending SSL data when waiting for socket input

When TLS is in use, checking the readiness of the underlying FD is insufficient
for determining if there is data available to be read. So before polling the
FD, check if there is any buffered data in the TLS layer and use that first.

ASTERISK-28562 #close
Reported by: Robert Sutton

Change-Id: I95fcb3e2004700d5cf8e5ee04943f0115b15e10d
This commit is contained in:
Sean Bright
2019-11-26 14:24:10 -05:00
parent cee68ea4f2
commit 87110c1bdf
5 changed files with 51 additions and 4 deletions

View File

@@ -392,7 +392,7 @@ static void websocket_cb(struct ast_websocket *session, struct ast_variable *par
transport = create_data.transport;
read_data.transport = transport;
while (ast_wait_for_input(ast_websocket_fd(session), -1) > 0) {
while (ast_websocket_wait_for_input(session, -1) > 0) {
enum ast_websocket_opcode opcode;
int fragmented;