From 4c1d408dff014760ba7257d3562e4a890a5a21da Mon Sep 17 00:00:00 2001 From: Jason Frame Date: Fri, 28 Aug 2015 13:22:37 +0100 Subject: [PATCH] fix detection of websocket close event MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit “bits” field is not a bitmask so & comparison is incorrect, compare for equality instead --- mongoose.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mongoose.c b/mongoose.c index 1c3a6e601d..037387fc36 100644 --- a/mongoose.c +++ b/mongoose.c @@ -4121,7 +4121,7 @@ static void read_websocket(struct mg_connection *conn) { // Exit the loop if callback signalled to exit, // or "connection close" opcode received. - if ((bits & WEBSOCKET_OPCODE_CONNECTION_CLOSE) || + if (((bits & 0x0F) == WEBSOCKET_OPCODE_CONNECTION_CLOSE) || (conn->ctx->callbacks.websocket_data != NULL && !conn->ctx->callbacks.websocket_data(conn, bits, data, data_len))) { stop = 1;