Improvement for mg_send #1876
LorenzoCarretta
started this conversation in
Feature requests
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello,
first of all, I wanted to say I really appreciate what you're doing here, this library is very good.
I wanted to suggest little improvement on the use of mg_send, most of all when using chunks.
I've been passing long amount of data in chunks and I've seen an issue I managed to fix on my part, but I think someone else could have experienced it so I'd like to suggest an improvement.
While passing chunks using mg_http_write_chunk, I've had some connection releted issue (slow network). Every now and then the mg_send inside mg_http_write_chunk would fail and couldn't allocate enough memory to send the data. I think this is because of the slow connection and the data wasn't send out fast enough so it would accumulate until it couldn't allocate more memory, but that just a theory.
Final result was that data received on the other side was missing parts, since some mg_send would fail, or even crashing for "invalid chunk".
Still the issue I'm proposing is that mg_http_write_chunk returns void and also inside it no check is done about mg_send being created correctly, so what I suggest is to return some value so that devs could do some flow control and retry if sending fails.
One think I'd like to bring to attention is that sometimes even the first mg_print or the final mg_send would be failing, and not only the middle mg_send with the data buffer, so I used a sort of status_map to tell at which of the 3 (header, data, "\r\n") it was failing.
Thank you !
EDIT: I forgot to say I'm using mongoose v7.6
Beta Was this translation helpful? Give feedback.
All reactions