Skip to content

Conversation

@javalikescript
Copy link
Contributor

@javalikescript javalikescript commented Nov 17, 2024

Protect async send() arguments using a mutex.
Use copy for async arguments rather than Lua reference.
Clear arguments in callback and before sending rather than after.
Keep existing and possibly weird behavior.
Allow async to use a FIFO queue.

Fixes #505

@javalikescript javalikescript marked this pull request as ready for review November 23, 2024 07:52
src/async.c Outdated
asarg->max = max;
ret = uv_mutex_init(&asarg->mutex);
if (ret < 0) { // unlikely
abort();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we shouldn't be aborting the program, this should be reported as a fail

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in commit 9fa42ef

@javalikescript
Copy link
Contributor Author

I added the FIFO queue because it was mentioned in the issue #505 and made it optional for the sake of compatibility.
I also wanted to keep the libuv behavior, to coalesce calls, when there is no queue nor data.

The issue is quite clear but the fix in this PR is aguable so do not hesitate if you think about any other option.

I could remove the queue from this PR, as this is a pure luv feature which will have to be supported in the long run!

Thank you for your help

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

memory leak related to uv.send_async

3 participants