Move libuv calls to correct thread#1197
Merged
johnhaley81 merged 5 commits intonodegit:masternodegit/nodegit:masterfrom Feb 6, 2017
Merged
Move libuv calls to correct thread#1197johnhaley81 merged 5 commits intonodegit:masternodegit/nodegit:masterfrom
johnhaley81 merged 5 commits intonodegit:masternodegit/nodegit:masterfrom
Conversation
Collaborator
Author
|
This was tested for stability in a staging GitKraken build, we didn't run into any problems. |
Collaborator
|
💯 Memory leak fixes and stability increases. 💯 @srajko talked offline about some naming issues that the PR brought out to the front. Namely that We both decided that we can update the names of the underlying callback system in a different PR and that this is GTG. |
tommoor
pushed a commit
to goabstract/nodegit
that referenced
this pull request
Mar 27, 2017
Move libuv calls to correct thread
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR removes
uv_async_init/uv_closecalls that were being called each time we were making callbacks from async threadpool threads into the main thread (for example, for clone progress callbacks). The change was prompted by Axosoft/nsfw#12 - in our case, theuv_async_initcalls were being called from threadpool threads and that violated libuv's thread safety requirements.The fix was to move the logic for these types of callbacks (I call them reverse callbacks in the code, since they are callbacks from the async threadpool code back into the main loop code) into our ThreadPool class, which now uses a single async handle and an internal queue to schedule these callbacks.
While at it, I also removed our last use of
sleep_for_msand replaced it with a semaphore.We also had a
returnthat would circumvent theuv_close-nodegit/generate/templates/partials/field_accessors.cc
Line 142 in de3583b
Finally, the batons we were using for these reverse callbacks were dynamically allocated and never deallocated. I took out the dynamic allocation to avoid this problem.