Using Mongoose 6.11
I have a system that is raising an alarm every 30 seconds upto a maximum of 750 alarms, from a UDP connection.
This causes triggers to generate data, which we need to send to websocket clients
We are multicasting this data, every time a new alarm arrives, using this for loop
for (c = mg_next(mg_AllConns.mgr, NULL); c != NULL; c = mg_next(mg_AllConns.mgr, c))
mg_send_websocket_frame(c, WEBSOCKET_OP_TEXT, strResponse.c_str(), strResponse.size());
the size of the data will build to a maximum of ~750kB
At random points we will either get an exception in the
if ((p = (char *) MBUF_REALLOC(a->buf, new_size)) != NULL)
or in the
memcpy(a->buf + off, buf, len); - changed this to memmove(a->buf + off, buf, len);
in case we had memory overlap, but still had the exception.
One theory we had was that the send doesn't happen instantly, and the REALLOC, or the memcpy/memmove, was corrupting data before it was sent.
we can't wait for the mg_send_websocket_frame to return, as it's a void function.
Is there something I may be missing that is causing my issues?