luvit / luv

Bare libuv bindings for lua
Apache License 2.0
832 stars 187 forks source link

Protect async send from misuse #725

Closed javalikescript closed 2 weeks ago

javalikescript commented 1 month ago

This is a proposal to mitigate the async send issues, see #505 ⚠️This is a breaking change as some misuse could work but with unexpected behavior.

Using arguments when calling async send is helpful but does not match the libuv implementation that will coalesce calls. Properly supporting multiple calls is a lot of work and may not be interesting for luv.

I propose to restrict the usage by allowing arguments only when async send is used just once. It is still possible to call multiple times async send without arguments which is the libuv API. It seems to me to be a simple but necessary fix.

Another option would be to use a lock to be able to change the arguments and free the not yet received ones, but there will be no guaranty on which arguments will be effectively received. This option is only interesting to avoid breaking existing misuse.

javalikescript commented 2 weeks ago

Closing in favor of #729