René's URL Explorer Experiment


Title: Move libuv calls to correct thread by srajko · Pull Request #1197 · nodegit/nodegit · GitHub

Open Graph Title: Move libuv calls to correct thread by srajko · Pull Request #1197 · nodegit/nodegit

X Title: Move libuv calls to correct thread by srajko · Pull Request #1197 · nodegit/nodegit

Description: This PR removes uv_async_init / uv_close calls 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, the uv_async_init calls 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_ms and replaced it with a semaphore. We also had a return that would circumvent the uv_close - nodegit/generate/templates/partials/field_accessors.cc Line 142 in de3583b return; . With this change, that problem goes away. 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.

Open Graph Description: This PR removes uv_async_init / uv_close calls that were being called each time we were making callbacks from async threadpool threads into the main thread (for example, for clone progress callback...

X Description: This PR removes uv_async_init / uv_close calls that were being called each time we were making callbacks from async threadpool threads into the main thread (for example, for clone progress callback...

Opengraph URL: https://github.com/nodegit/nodegit/pull/1197

X: @github

direct link

Domain: github.com

route-pattern/:user_id/:repository/pull/:id/files(.:format)
route-controllerpull_requests
route-actionfiles
fetch-noncev2:4c33e26d-7bdc-3b70-291b-d9fbacbf77d3
current-catalog-service-hashae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b
request-id86E0:153D66:CBEE4:113F8B:6A5B5468
html-safe-noncef6017cd6e5292e189f50a249e2e73f76fd541f4c61f8830c8f9eeae14cb4e3c2
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4NkUwOjE1M0Q2NjpDQkVFNDoxMTNGOEI6NkE1QjU0NjgiLCJ2aXNpdG9yX2lkIjoiODcyMTQ3MDA5MzIzMzE4MTgwMCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmaca0fbcf6103a9223e0fd09cc0612933825a4f3019339556e7f58a135bd9474ac1
hovercard-subject-tagpull_request:103417193
github-keyboard-shortcutsrepository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///pull_requests/show/files
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/nodegit/nodegit/pull/1197/files
twitter:imagehttps://avatars.githubusercontent.com/u/291007?s=400&v=4
twitter:cardsummary_large_image
og:imagehttps://avatars.githubusercontent.com/u/291007?s=400&v=4
og:image:altThis PR removes uv_async_init / uv_close calls that were being called each time we were making callbacks from async threadpool threads into the main thread (for example, for clone progress callback...
og:site_nameGitHub
og:typeobject
hostnamegithub.com
expected-hostnamegithub.com
None5290d7e14309ad1e76106a9c4237bd1041517e83ea182c8ab756752cb0c6940b
turbo-cache-controlno-preview
diff-viewunified
go-importgithub.com/nodegit/nodegit git https://github.com/nodegit/nodegit.git
octolytics-dimension-user_id657068
octolytics-dimension-user_loginnodegit
octolytics-dimension-repository_id1383170
octolytics-dimension-repository_nwonodegit/nodegit
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id1383170
octolytics-dimension-repository_network_root_nwonodegit/nodegit
turbo-body-classeslogged-out env-production page-responsive full-width
disable-turbotrue
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release9c975978430e9ad293956f2bbdaf153b1bd84a99
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/nodegit/nodegit/pull/1197/files#start-of-content
https://github.com/
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fnodegit%2Fnodegit%2Fpull%2F1197%2Ffiles
GitHub CopilotWrite better code with AIhttps://github.com/features/copilot
GitHub Copilot appDirect agents from issue to mergehttps://github.com/features/ai/github-app
MCP RegistryNewIntegrate external toolshttps://github.com/mcp
ActionsAutomate any workflowhttps://github.com/features/actions
CodespacesInstant dev environmentshttps://github.com/features/codespaces
IssuesPlan and track workhttps://github.com/features/issues
Code ReviewManage code changeshttps://github.com/features/code-review
GitHub Advanced SecurityFind and fix vulnerabilitieshttps://github.com/security/advanced-security
Code securitySecure your code as you buildhttps://github.com/security/advanced-security/code-security
Secret protectionStop leaks before they starthttps://github.com/security/advanced-security/secret-protection
Why GitHubhttps://github.com/why-github
Documentationhttps://docs.github.com
Bloghttps://github.blog
Changeloghttps://github.blog/changelog
Marketplacehttps://github.com/marketplace
View all featureshttps://github.com/features
Enterpriseshttps://github.com/enterprise
Small and medium teamshttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
App Modernizationhttps://github.com/solutions/use-case/app-modernization
DevSecOpshttps://github.com/solutions/use-case/devsecops
DevOpshttps://github.com/solutions/use-case/devops
CI/CDhttps://github.com/solutions/use-case/ci-cd
View all use caseshttps://github.com/solutions/use-case
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
View all industrieshttps://github.com/solutions/industry
View all solutionshttps://github.com/solutions
AIhttps://github.com/resources/articles?topic=ai
Software Developmenthttps://github.com/resources/articles?topic=software-development
DevOpshttps://github.com/resources/articles?topic=devops
Securityhttps://github.com/resources/articles?topic=security
View all topicshttps://github.com/resources/articles
Customer storieshttps://github.com/customer-stories
Events & webinarshttps://github.com/resources/events
Ebooks & reportshttps://github.com/resources/whitepapers
Business insightshttps://github.com/solutions/executive-insights
GitHub Skillshttps://skills.github.com
Documentationhttps://docs.github.com
Customer supporthttps://support.github.com
Community forumhttps://github.com/orgs/community/discussions
Trust centerhttps://github.com/trust-center
Partnershttps://github.com/partners
View all resourceshttps://github.com/resources
GitHub SponsorsFund open source developershttps://github.com/open-source/sponsors
Security Labhttps://securitylab.github.com
Maintainer Communityhttps://maintainers.github.com
Acceleratorhttps://github.com/open-source/accelerator
GitHub Starshttps://stars.github.com
Archive Programhttps://archiveprogram.github.com
Topicshttps://github.com/topics
Trendinghttps://github.com/trending
Collectionshttps://github.com/collections
Enterprise platformAI-powered developer platformhttps://github.com/enterprise
GitHub Advanced SecurityEnterprise-grade security featureshttps://github.com/security/advanced-security
Copilot for BusinessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Pricinghttps://github.com/pricing
Search syntax tipshttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
documentationhttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fnodegit%2Fnodegit%2Fpull%2F1197%2Ffiles
Sign up https://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fpull_requests%2Fshow%2Ffiles&source=header-repo&source_repo=nodegit%2Fnodegit
Reloadhttps://github.com/nodegit/nodegit/pull/1197/files
Reloadhttps://github.com/nodegit/nodegit/pull/1197/files
Reloadhttps://github.com/nodegit/nodegit/pull/1197/files
Please reload this pagehttps://github.com/nodegit/nodegit/pull/1197/files
nodegit https://github.com/nodegit
nodegithttps://github.com/nodegit/nodegit
Notifications https://github.com/login?return_to=%2Fnodegit%2Fnodegit
Fork 698 https://github.com/login?return_to=%2Fnodegit%2Fnodegit
Star 5.8k https://github.com/login?return_to=%2Fnodegit%2Fnodegit
Code https://github.com/nodegit/nodegit
Issues 343 https://github.com/nodegit/nodegit/issues
Pull requests 20 https://github.com/nodegit/nodegit/pulls
Actions https://github.com/nodegit/nodegit/actions
Projects https://github.com/nodegit/nodegit/projects
Security and quality 0 https://github.com/nodegit/nodegit/security
Insights https://github.com/nodegit/nodegit/pulse
Code https://github.com/nodegit/nodegit
Issues https://github.com/nodegit/nodegit/issues
Pull requests https://github.com/nodegit/nodegit/pulls
Actions https://github.com/nodegit/nodegit/actions
Projects https://github.com/nodegit/nodegit/projects
Security and quality https://github.com/nodegit/nodegit/security
Insights https://github.com/nodegit/nodegit/pulse
Sign up for GitHub https://github.com/signup?return_to=%2Fnodegit%2Fnodegit%2Fissues%2Fnew%2Fchoose
terms of servicehttps://docs.github.com/terms
privacy statementhttps://docs.github.com/privacy
Sign inhttps://github.com/login?return_to=%2Fnodegit%2Fnodegit%2Fissues%2Fnew%2Fchoose
johnhaley81https://github.com/johnhaley81
nodegit:masterhttps://github.com/nodegit/nodegit/tree/master
srajko:uv_close-fixhttps://github.com/srajko/nodegit/tree/uv_close-fix
Conversation 2 https://github.com/nodegit/nodegit/pull/1197
Commits 5 https://github.com/nodegit/nodegit/pull/1197/commits
Checks 0 https://github.com/nodegit/nodegit/pull/1197/checks
Files changed https://github.com/nodegit/nodegit/pull/1197/files
Please reload this pagehttps://github.com/nodegit/nodegit/pull/1197/files
Move libuv calls to correct thread https://github.com/nodegit/nodegit/pull/1197/files#top
Show all changes 5 commits https://github.com/nodegit/nodegit/pull/1197/files
9c01821 Add support for reverse callbacks to ThreadPool srajko Jan 30, 2017 https://github.com/nodegit/nodegit/pull/1197/commits/9c01821796dee6608aafd6cb7af4a0fbe1d83504
c0c383f Use ExecuteReverseCallback srajko Jan 30, 2017 https://github.com/nodegit/nodegit/pull/1197/commits/c0c383fc3a82e3a2028b7e7e92f00aa11c8dc56f
884900f Allocate baton on stack srajko Jan 30, 2017 https://github.com/nodegit/nodegit/pull/1197/commits/884900ff362413d663522bdd8218f5395ef134fd
acb6c41 Remove sleep_for_ms srajko Jan 30, 2017 https://github.com/nodegit/nodegit/pull/1197/commits/acb6c41a7a82972f67cbcaf888febceff03a3fa3
6d7762b Unreference handle to allow node to terminate srajko Feb 6, 2017 https://github.com/nodegit/nodegit/pull/1197/commits/6d7762b9ce475bfa5db9249598f6629db636d458
Clear filters https://github.com/nodegit/nodegit/pull/1197/files
Please reload this pagehttps://github.com/nodegit/nodegit/pull/1197/files
Please reload this pagehttps://github.com/nodegit/nodegit/pull/1197/files
async_baton.h https://github.com/nodegit/nodegit/pull/1197/files#diff-ac15ad8f3aa49262cbbc1dcb2377cb6f3f1f1a7ca3b8593d9df294487de32442
sleep_for_ms.h https://github.com/nodegit/nodegit/pull/1197/files#diff-d13d6c368f22f40e0b06f93c49e9215495c47301217d12dfc833262b9e1da0cd
thread_pool.h https://github.com/nodegit/nodegit/pull/1197/files#diff-a4a6f776389c716096e228f798faa00dccca53782c0ca39a42ce03fbca0b1c0b
sleep_for_ms.cc https://github.com/nodegit/nodegit/pull/1197/files#diff-66377f6bb20f2d37795e2bde1486902ff4bd150ab92d66d2ece0e3b3fb82bb66
thread_pool.cc https://github.com/nodegit/nodegit/pull/1197/files#diff-925de64dd64c4ad4d4bca7bd73cd9f8af9f55a25d1d8b059f7e68b1922c6b4f7
callback_helpers.cc https://github.com/nodegit/nodegit/pull/1197/files#diff-69c0456eeba2003f1d45121f0928c0eecea45117994a7221a16bc0884f14709a
field_accessors.cc https://github.com/nodegit/nodegit/pull/1197/files#diff-191a2d4dc20d49214a2b55f9d415677dc81fd14fe7c560a7598aefb46a0169d3
binding.gyp https://github.com/nodegit/nodegit/pull/1197/files#diff-e4864b3e985981d1b9cc4dbd855f8eab136659d24d7996a19acf61e8b38e1aa6
class_header.h https://github.com/nodegit/nodegit/pull/1197/files#diff-25ee49e4f3bdf45b52b23f17fb4fed35cd78702ba9e670d4f51cdfee3ae4296a
struct_header.h https://github.com/nodegit/nodegit/pull/1197/files#diff-46b0fc4d3930421a977f56345238c15ad1e71654d1a831d9a011f8ca1784181d
generate/templates/manual/include/async_baton.hhttps://github.com/nodegit/nodegit/pull/1197/files#diff-ac15ad8f3aa49262cbbc1dcb2377cb6f3f1f1a7ca3b8593d9df294487de32442
View file https://github.com/srajko/nodegit/blob/6d7762b9ce475bfa5db9249598f6629db636d458/generate/templates/manual/include/async_baton.h
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/nodegit/nodegit/pull/1197/{{ revealButtonHref }}
https://github.com/nodegit/nodegit/pull/1197/files#diff-ac15ad8f3aa49262cbbc1dcb2377cb6f3f1f1a7ca3b8593d9df294487de32442
https://github.com/nodegit/nodegit/pull/1197/files#diff-ac15ad8f3aa49262cbbc1dcb2377cb6f3f1f1a7ca3b8593d9df294487de32442
https://github.com/nodegit/nodegit/pull/1197/files#diff-ac15ad8f3aa49262cbbc1dcb2377cb6f3f1f1a7ca3b8593d9df294487de32442
generate/templates/manual/include/functions/sleep_for_ms.hhttps://github.com/nodegit/nodegit/pull/1197/files#diff-d13d6c368f22f40e0b06f93c49e9215495c47301217d12dfc833262b9e1da0cd
View file https://github.com/nodegit/nodegit/blob/5b4bb8c31ac831c2d23ef6db533cdeacbd4b638c/generate/templates/manual/include/functions/sleep_for_ms.h
Open in desktop https://desktop.github.com
Please reload this pagehttps://github.com/nodegit/nodegit/pull/1197/files
generate/templates/manual/include/thread_pool.hhttps://github.com/nodegit/nodegit/pull/1197/files#diff-a4a6f776389c716096e228f798faa00dccca53782c0ca39a42ce03fbca0b1c0b
View file https://github.com/srajko/nodegit/blob/6d7762b9ce475bfa5db9249598f6629db636d458/generate/templates/manual/include/thread_pool.h
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/nodegit/nodegit/pull/1197/{{ revealButtonHref }}
https://github.com/nodegit/nodegit/pull/1197/files#diff-a4a6f776389c716096e228f798faa00dccca53782c0ca39a42ce03fbca0b1c0b
https://github.com/nodegit/nodegit/pull/1197/files#diff-a4a6f776389c716096e228f798faa00dccca53782c0ca39a42ce03fbca0b1c0b
https://github.com/nodegit/nodegit/pull/1197/files#diff-a4a6f776389c716096e228f798faa00dccca53782c0ca39a42ce03fbca0b1c0b
generate/templates/manual/src/functions/sleep_for_ms.cchttps://github.com/nodegit/nodegit/pull/1197/files#diff-66377f6bb20f2d37795e2bde1486902ff4bd150ab92d66d2ece0e3b3fb82bb66
View file https://github.com/nodegit/nodegit/blob/5b4bb8c31ac831c2d23ef6db533cdeacbd4b638c/generate/templates/manual/src/functions/sleep_for_ms.cc
Open in desktop https://desktop.github.com
Please reload this pagehttps://github.com/nodegit/nodegit/pull/1197/files
generate/templates/manual/src/thread_pool.cchttps://github.com/nodegit/nodegit/pull/1197/files#diff-925de64dd64c4ad4d4bca7bd73cd9f8af9f55a25d1d8b059f7e68b1922c6b4f7
View file https://github.com/srajko/nodegit/blob/6d7762b9ce475bfa5db9249598f6629db636d458/generate/templates/manual/src/thread_pool.cc
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/nodegit/nodegit/pull/1197/{{ revealButtonHref }}
https://github.com/nodegit/nodegit/pull/1197/files#diff-925de64dd64c4ad4d4bca7bd73cd9f8af9f55a25d1d8b059f7e68b1922c6b4f7
https://github.com/nodegit/nodegit/pull/1197/files#diff-925de64dd64c4ad4d4bca7bd73cd9f8af9f55a25d1d8b059f7e68b1922c6b4f7
https://github.com/nodegit/nodegit/pull/1197/files#diff-925de64dd64c4ad4d4bca7bd73cd9f8af9f55a25d1d8b059f7e68b1922c6b4f7
generate/templates/partials/callback_helpers.cchttps://github.com/nodegit/nodegit/pull/1197/files#diff-69c0456eeba2003f1d45121f0928c0eecea45117994a7221a16bc0884f14709a
View file https://github.com/srajko/nodegit/blob/6d7762b9ce475bfa5db9249598f6629db636d458/generate/templates/partials/callback_helpers.cc
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/nodegit/nodegit/pull/1197/{{ revealButtonHref }}
https://github.com/nodegit/nodegit/pull/1197/files#diff-69c0456eeba2003f1d45121f0928c0eecea45117994a7221a16bc0884f14709a
https://github.com/nodegit/nodegit/pull/1197/files#diff-69c0456eeba2003f1d45121f0928c0eecea45117994a7221a16bc0884f14709a
https://github.com/nodegit/nodegit/pull/1197/files#diff-69c0456eeba2003f1d45121f0928c0eecea45117994a7221a16bc0884f14709a
https://github.com/nodegit/nodegit/pull/1197/files#diff-69c0456eeba2003f1d45121f0928c0eecea45117994a7221a16bc0884f14709a
https://github.com/nodegit/nodegit/pull/1197/files#diff-69c0456eeba2003f1d45121f0928c0eecea45117994a7221a16bc0884f14709a
https://github.com/nodegit/nodegit/pull/1197/files#diff-69c0456eeba2003f1d45121f0928c0eecea45117994a7221a16bc0884f14709a
https://github.com/nodegit/nodegit/pull/1197/files#diff-69c0456eeba2003f1d45121f0928c0eecea45117994a7221a16bc0884f14709a
Please reload this pagehttps://github.com/nodegit/nodegit/pull/1197/files
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.