Message ID | 20230920105526.191948-2-michael.bella-oss@weidmueller.com |
---|---|
State | Accepted |
Delegated to: | Stefano Babic |
Headers | show |
Series | [1/2] mongoose: use websocket flag of connection struct | expand |
I noticed that the patches are accepted in patchwork, but they are not present in the git repository. I there anything to do from my side to get the patches applied? michael....@weidmueller.com schrieb am Mittwoch, 20. September 2023 um 12:56:10 UTC+2: > From: Michael Bella <michae...@weidmueller.com> > > After the update of mongoose webserver to version 7.8 the heartbeat of > the websocket connection was removed. This patch adds a heartbeat that > sends a ping message every 20 seconds. > > Signed-off-by: Michael Bella <michae...@weidmueller.com> > --- > mongoose/mongoose_interface.c | 11 +++++++++++ > 1 file changed, 11 insertions(+) > > diff --git a/mongoose/mongoose_interface.c b/mongoose/mongoose_interface.c > index 09d564e..d343a5e 100644 > --- a/mongoose/mongoose_interface.c > +++ b/mongoose/mongoose_interface.c > @@ -360,6 +360,7 @@ static void restart_handler(struct mg_connection *nc, > void *ev_data) > static void broadcast_callback(struct mg_connection *nc, int ev, > void __attribute__ ((__unused__)) *ev_data, void __attribute__ > ((__unused__)) *fn_data) > { > + static uint64_t last_io_time = 0; > if (ev == MG_EV_READ) { > struct mg_connection *t; > for (t = nc->mgr->conns; t != NULL; t = t->next) { > @@ -367,6 +368,16 @@ static void broadcast_callback(struct mg_connection > *nc, int ev, > mg_ws_send(t,(char *)nc->recv.buf, nc->recv.len, WEBSOCKET_OP_TEXT); > } > mg_iobuf_del(&nc->recv, 0, nc->recv.len); > + last_io_time = mg_millis(); > + } else if (ev == MG_EV_POLL) { > + struct mg_connection *t; > + uint64_t now = *((uint64_t *)ev_data); > + if (now < last_io_time + 20000) return; > + for (t = nc->mgr->conns; t != NULL; t = t->next) { > + if (!t->is_websocket) continue; > + mg_ws_send(t, "", 0, WEBSOCKET_OP_PING); > + } > + last_io_time = now; > } > } > > -- > 2.30.2 > >
Hi Michael, On 29.01.24 10:08, Michael Bella wrote: > I noticed that the patches are accepted in patchwork, but they are not > present in the git repository. I there anything to do from my side to > get the patches applied? > Yes - I never saw this patch, it looks like it silently landed in SPAM. Can you check again your patches and post again the ones are missing ? Thanks ! Best regards, Stefano > michael....@weidmueller.com schrieb am Mittwoch, 20. September 2023 um > 12:56:10 UTC+2: > > From: Michael Bella <michae...@weidmueller.com> > > After the update of mongoose webserver to version 7.8 the heartbeat of > the websocket connection was removed. This patch adds a heartbeat that > sends a ping message every 20 seconds. > > Signed-off-by: Michael Bella <michae...@weidmueller.com> > --- > mongoose/mongoose_interface.c | 11 +++++++++++ > 1 file changed, 11 insertions(+) > > diff --git a/mongoose/mongoose_interface.c > b/mongoose/mongoose_interface.c > index 09d564e..d343a5e 100644 > --- a/mongoose/mongoose_interface.c > +++ b/mongoose/mongoose_interface.c > @@ -360,6 +360,7 @@ static void restart_handler(struct mg_connection > *nc, void *ev_data) > static void broadcast_callback(struct mg_connection *nc, int ev, > void __attribute__ ((__unused__)) *ev_data, void __attribute__ > ((__unused__)) *fn_data) > { > + static uint64_t last_io_time = 0; > if (ev == MG_EV_READ) { > struct mg_connection *t; > for (t = nc->mgr->conns; t != NULL; t = t->next) { > @@ -367,6 +368,16 @@ static void broadcast_callback(struct > mg_connection *nc, int ev, > mg_ws_send(t,(char *)nc->recv.buf, nc->recv.len, WEBSOCKET_OP_TEXT); > } > mg_iobuf_del(&nc->recv, 0, nc->recv.len); > + last_io_time = mg_millis(); > + } else if (ev == MG_EV_POLL) { > + struct mg_connection *t; > + uint64_t now = *((uint64_t *)ev_data); > + if (now < last_io_time + 20000) return; > + for (t = nc->mgr->conns; t != NULL; t = t->next) { > + if (!t->is_websocket) continue; > + mg_ws_send(t, "", 0, WEBSOCKET_OP_PING); > + } > + last_io_time = now; > } > } > > -- > 2.30.2 > > -- > You received this message because you are subscribed to the Google > Groups "swupdate" group. > To unsubscribe from this group and stop receiving emails from it, send > an email to swupdate+unsubscribe@googlegroups.com > <mailto:swupdate+unsubscribe@googlegroups.com>. > To view this discussion on the web visit > https://groups.google.com/d/msgid/swupdate/8fa78c0c-5cd1-41ad-901e-c803afa2b364n%40googlegroups.com <https://groups.google.com/d/msgid/swupdate/8fa78c0c-5cd1-41ad-901e-c803afa2b364n%40googlegroups.com?utm_medium=email&utm_source=footer>.
Hey Stefano, I reposted my patches. Thank you. Best regards, Michael On Monday, January 29, 2024 at 11:22:50 AM UTC+1 Stefano Babic wrote: > Hi Michael, > > On 29.01.24 10:08, Michael Bella wrote: > > I noticed that the patches are accepted in patchwork, but they are not > > present in the git repository. I there anything to do from my side to > > get the patches applied? > > > > Yes - I never saw this patch, it looks like it silently landed in SPAM. > > Can you check again your patches and post again the ones are missing ? > Thanks ! > > Best regards, > Stefano > > > michael....@weidmueller.com schrieb am Mittwoch, 20. September 2023 um > > 12:56:10 UTC+2: > > > > From: Michael Bella <michae...@weidmueller.com> > > > > After the update of mongoose webserver to version 7.8 the heartbeat of > > the websocket connection was removed. This patch adds a heartbeat that > > sends a ping message every 20 seconds. > > > > Signed-off-by: Michael Bella <michae...@weidmueller.com> > > --- > > mongoose/mongoose_interface.c | 11 +++++++++++ > > 1 file changed, 11 insertions(+) > > > > diff --git a/mongoose/mongoose_interface.c > > b/mongoose/mongoose_interface.c > > index 09d564e..d343a5e 100644 > > --- a/mongoose/mongoose_interface.c > > +++ b/mongoose/mongoose_interface.c > > @@ -360,6 +360,7 @@ static void restart_handler(struct mg_connection > > *nc, void *ev_data) > > static void broadcast_callback(struct mg_connection *nc, int ev, > > void __attribute__ ((__unused__)) *ev_data, void __attribute__ > > ((__unused__)) *fn_data) > > { > > + static uint64_t last_io_time = 0; > > if (ev == MG_EV_READ) { > > struct mg_connection *t; > > for (t = nc->mgr->conns; t != NULL; t = t->next) { > > @@ -367,6 +368,16 @@ static void broadcast_callback(struct > > mg_connection *nc, int ev, > > mg_ws_send(t,(char *)nc->recv.buf, nc->recv.len, WEBSOCKET_OP_TEXT); > > } > > mg_iobuf_del(&nc->recv, 0, nc->recv.len); > > + last_io_time = mg_millis(); > > + } else if (ev == MG_EV_POLL) { > > + struct mg_connection *t; > > + uint64_t now = *((uint64_t *)ev_data); > > + if (now < last_io_time + 20000) return; > > + for (t = nc->mgr->conns; t != NULL; t = t->next) { > > + if (!t->is_websocket) continue; > > + mg_ws_send(t, "", 0, WEBSOCKET_OP_PING); > > + } > > + last_io_time = now; > > } > > } > > > > -- > > 2.30.2 > > > > -- > > You received this message because you are subscribed to the Google > > Groups "swupdate" group. > > To unsubscribe from this group and stop receiving emails from it, send > > an email to swupdate+u...@googlegroups.com > > <mailto:swupdate+u...@googlegroups.com>. > > To view this discussion on the web visit > > > https://groups.google.com/d/msgid/swupdate/8fa78c0c-5cd1-41ad-901e-c803afa2b364n%40googlegroups.com > < > https://groups.google.com/d/msgid/swupdate/8fa78c0c-5cd1-41ad-901e-c803afa2b364n%40googlegroups.com?utm_medium=email&utm_source=footer > >. > >
On 31.01.24 11:16, Michael Bella wrote: > Hey Stefano, > I reposted my patches. Thank you. ...and I merged them ! Regards, Stefano > Best regards, > Michael > > On Monday, January 29, 2024 at 11:22:50 AM UTC+1 Stefano Babic wrote: > > Hi Michael, > > On 29.01.24 10:08, Michael Bella wrote: > > I noticed that the patches are accepted in patchwork, but they > are not > > present in the git repository. I there anything to do from my > side to > > get the patches applied? > > > > Yes - I never saw this patch, it looks like it silently landed in SPAM. > > Can you check again your patches and post again the ones are missing ? > Thanks ! > > Best regards, > Stefano > > > michael....@weidmueller.com schrieb am Mittwoch, 20. September > 2023 um > > 12:56:10 UTC+2: > > > > From: Michael Bella <michae...@weidmueller.com> > > > > After the update of mongoose webserver to version 7.8 the > heartbeat of > > the websocket connection was removed. This patch adds a heartbeat > that > > sends a ping message every 20 seconds. > > > > Signed-off-by: Michael Bella <michae...@weidmueller.com> > > --- > > mongoose/mongoose_interface.c | 11 +++++++++++ > > 1 file changed, 11 insertions(+) > > > > diff --git a/mongoose/mongoose_interface.c > > b/mongoose/mongoose_interface.c > > index 09d564e..d343a5e 100644 > > --- a/mongoose/mongoose_interface.c > > +++ b/mongoose/mongoose_interface.c > > @@ -360,6 +360,7 @@ static void restart_handler(struct mg_connection > > *nc, void *ev_data) > > static void broadcast_callback(struct mg_connection *nc, int ev, > > void __attribute__ ((__unused__)) *ev_data, void __attribute__ > > ((__unused__)) *fn_data) > > { > > + static uint64_t last_io_time = 0; > > if (ev == MG_EV_READ) { > > struct mg_connection *t; > > for (t = nc->mgr->conns; t != NULL; t = t->next) { > > @@ -367,6 +368,16 @@ static void broadcast_callback(struct > > mg_connection *nc, int ev, > > mg_ws_send(t,(char *)nc->recv.buf, nc->recv.len, WEBSOCKET_OP_TEXT); > > } > > mg_iobuf_del(&nc->recv, 0, nc->recv.len); > > + last_io_time = mg_millis(); > > + } else if (ev == MG_EV_POLL) { > > + struct mg_connection *t; > > + uint64_t now = *((uint64_t *)ev_data); > > + if (now < last_io_time + 20000) return; > > + for (t = nc->mgr->conns; t != NULL; t = t->next) { > > + if (!t->is_websocket) continue; > > + mg_ws_send(t, "", 0, WEBSOCKET_OP_PING); > > + } > > + last_io_time = now; > > } > > } > > > > -- > > 2.30.2 > > > > -- > > You received this message because you are subscribed to the Google > > Groups "swupdate" group. > > To unsubscribe from this group and stop receiving emails from it, > send > > an email to swupdate+u...@googlegroups.com > > <mailto:swupdate+u...@googlegroups.com>. > > To view this discussion on the web visit > > > https://groups.google.com/d/msgid/swupdate/8fa78c0c-5cd1-41ad-901e-c803afa2b364n%40googlegroups.com <https://groups.google.com/d/msgid/swupdate/8fa78c0c-5cd1-41ad-901e-c803afa2b364n%40googlegroups.com> <https://groups.google.com/d/msgid/swupdate/8fa78c0c-5cd1-41ad-901e-c803afa2b364n%40googlegroups.com?utm_medium=email&utm_source=footer <https://groups.google.com/d/msgid/swupdate/8fa78c0c-5cd1-41ad-901e-c803afa2b364n%40googlegroups.com?utm_medium=email&utm_source=footer>>. > > -- > You received this message because you are subscribed to the Google > Groups "swupdate" group. > To unsubscribe from this group and stop receiving emails from it, send > an email to swupdate+unsubscribe@googlegroups.com > <mailto:swupdate+unsubscribe@googlegroups.com>. > To view this discussion on the web visit > https://groups.google.com/d/msgid/swupdate/6425d26f-29ea-4313-953b-889ed21d28b7n%40googlegroups.com <https://groups.google.com/d/msgid/swupdate/6425d26f-29ea-4313-953b-889ed21d28b7n%40googlegroups.com?utm_medium=email&utm_source=footer>.
diff --git a/mongoose/mongoose_interface.c b/mongoose/mongoose_interface.c index 09d564e..d343a5e 100644 --- a/mongoose/mongoose_interface.c +++ b/mongoose/mongoose_interface.c @@ -360,6 +360,7 @@ static void restart_handler(struct mg_connection *nc, void *ev_data) static void broadcast_callback(struct mg_connection *nc, int ev, void __attribute__ ((__unused__)) *ev_data, void __attribute__ ((__unused__)) *fn_data) { + static uint64_t last_io_time = 0; if (ev == MG_EV_READ) { struct mg_connection *t; for (t = nc->mgr->conns; t != NULL; t = t->next) { @@ -367,6 +368,16 @@ static void broadcast_callback(struct mg_connection *nc, int ev, mg_ws_send(t,(char *)nc->recv.buf, nc->recv.len, WEBSOCKET_OP_TEXT); } mg_iobuf_del(&nc->recv, 0, nc->recv.len); + last_io_time = mg_millis(); + } else if (ev == MG_EV_POLL) { + struct mg_connection *t; + uint64_t now = *((uint64_t *)ev_data); + if (now < last_io_time + 20000) return; + for (t = nc->mgr->conns; t != NULL; t = t->next) { + if (!t->is_websocket) continue; + mg_ws_send(t, "", 0, WEBSOCKET_OP_PING); + } + last_io_time = now; } }