diff mbox series

[1/2] mongoose: use websocket flag of connection struct

Message ID 20230920105526.191948-1-michael.bella-oss@weidmueller.com
State Accepted
Delegated to: Stefano Babic
Headers show
Series [1/2] mongoose: use websocket flag of connection struct | expand

Commit Message

Michael Bella Sept. 20, 2023, 10:55 a.m. UTC
From: Michael Bella <michael.bella@weidmueller.com>

After the update of the mongoose webserver to version 7.8 new flags for
the connection struct were introduced. In the current version of
swupdate 'W' is set to the first position of the data array to mark
connections that use a websocket. For better readability the
is_websocket flag of the connection struct can be used.

Signed-off-by: Michael Bella <michael.bella@weidmueller.com>
---
 mongoose/mongoose_interface.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/mongoose/mongoose_interface.c b/mongoose/mongoose_interface.c
index 4b61acb..09d564e 100644
--- a/mongoose/mongoose_interface.c
+++ b/mongoose/mongoose_interface.c
@@ -363,7 +363,7 @@  static void broadcast_callback(struct mg_connection *nc, int ev,
 	if (ev == MG_EV_READ) {
 		struct mg_connection *t;
 		for (t = nc->mgr->conns; t != NULL; t = t->next) {
-			if (t->data[0] != 'W') continue;
+			if (!t->is_websocket) continue;
 			mg_ws_send(t,(char *)nc->recv.buf, nc->recv.len, WEBSOCKET_OP_TEXT);
 		}
 		mg_iobuf_del(&nc->recv, 0, nc->recv.len);
@@ -671,7 +671,6 @@  static void websocket_handler(struct mg_connection *nc, void *ev_data)
 {
 	struct mg_http_message *hm = (struct mg_http_message *) ev_data;
 	mg_ws_upgrade(nc, hm, NULL);
-	nc->data[0] = 'W';
 }
 
 static void ev_handler(struct mg_connection *nc, int ev, void *ev_data, void *fn_data)