-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Filter registration #3597
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Filter registration #3597
Conversation
1ccc242
to
d82c78d
Compare
Move the common initialization and cleanup methods to reduce unnecessary duplication.
523e553
to
b9b1222
Compare
Use the gcc-like memory barrier (__sync_synchronize) on mingw.
Previously we would set the global filter registry structure before adding filters to the structure, without a lock, which is quite racy. Now, register default filters during global registration and use an rwlock to read and write the filter registry (as appopriate).
b9b1222
to
0ad1391
Compare
Okay - I nailed down the problems on Windows; it turns out that my refactoring was a bit overly aggressive when it came to the windows CRT debug functions. Those must be first, before your first allocation. This is quite sensible, but not something that had occurred to me. In any case, I think this nicely tightens up the global setup and teardown, and makes our threads safer for the filters. This should be ready for review. |
return 0; | ||
} | ||
|
||
int git_openssl_set_locking(void) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thing is... this function isn't really about the streams. It's there to stop bindings from crashing when they use multiple threads without having to conditionally link to OpenSSL themselves.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes but short of deleting it, t this still seems to be the most logical file to move this function to.
0ad1391
to
075721a
Compare
075721a
to
82abd40
Compare
Does a similar change have to be made with the diff driver registry? |
What diff driver registry? |
I may be mistaken, but I thought this was it: https://github.com/libgit2/libgit2/blob/master/src/diff_driver.h#L13 |
Ah - no, those are per-repository and so have very different lifecycles. |
While reviewing #3564 , @carlosmn noticed that we were a bit racy in registration of merge drivers. This registration pattern was primarily copied from filter registration, so I wanted to fix up the existing code before banging on that.
Previously we would set the global filter registry structure before adding filters to the structure, without a lock, which is quite racy. Now, register default filters during global registration and use an rwlock to read and write the filter registry (as appropriate)