Thanks to visit codestin.com
Credit goes to github.com

Skip to content

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

Merged
merged 5 commits into from
Feb 19, 2016
Merged

Filter registration #3597

merged 5 commits into from
Feb 19, 2016

Conversation

ethomson
Copy link
Member

@ethomson ethomson commented Feb 7, 2016

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)

@ethomson ethomson force-pushed the filter_registration branch 2 times, most recently from 1ccc242 to d82c78d Compare February 8, 2016 22:16
Move the common initialization and cleanup methods to reduce
unnecessary duplication.
@ethomson ethomson force-pushed the filter_registration branch from 523e553 to b9b1222 Compare February 8, 2016 23:39
Edward Thomson added 3 commits February 8, 2016 16:30
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).
@ethomson ethomson force-pushed the filter_registration branch from b9b1222 to 0ad1391 Compare February 9, 2016 00:33
@ethomson
Copy link
Member Author

ethomson commented Feb 9, 2016

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)
Copy link
Member

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.

Copy link
Member Author

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.

@ethomson ethomson force-pushed the filter_registration branch from 0ad1391 to 075721a Compare February 10, 2016 01:55
@ethomson ethomson force-pushed the filter_registration branch from 075721a to 82abd40 Compare February 10, 2016 05:48
@stanhu
Copy link
Contributor

stanhu commented Feb 13, 2016

Does a similar change have to be made with the diff driver registry?

@ethomson
Copy link
Member Author

What diff driver registry?

@stanhu
Copy link
Contributor

stanhu commented Feb 13, 2016

I may be mistaken, but I thought this was it:

https://github.com/libgit2/libgit2/blob/master/src/diff_driver.h#L13

@ethomson
Copy link
Member Author

Ah - no, those are per-repository and so have very different lifecycles.

carlosmn added a commit that referenced this pull request Feb 19, 2016
@carlosmn carlosmn merged commit 78e16c3 into libgit2:master Feb 19, 2016
@ethomson ethomson deleted the filter_registration branch February 29, 2016 21:00
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.

3 participants