8000 Call git_threads_shutdown() after last handle get disposed by jbialobr · Pull Request #358 · libgit2/libgit2sharp · GitHub
[go: up one dir, main page]

Skip to content

Call git_threads_shutdown() after last handle get disposed #358

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

Closed
wants to merge 20 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
a309c19
Call git_threads_shutdown() after last handle get disposed
jbialobr Mar 1, 2013
79d4def
Corrected due to review comments
jbialobr Mar 1, 2013
9b864cd
Reverted changes done to SafeHandleBase.Dispose
jbialobr Mar 1, 2013
bdd45ed
Decrement when removing
jbialobr Mar 1, 2013
cd70dbc
Seal ReleaseHandle
jbialobr Mar 1, 2013
cbf5c69
InternalReleaseHandle -> ReleaseHandleImpl
jbialobr Mar 1, 2013
f90a967
Only call AddHandle when we know the handle is valid (i.e. ReleaseHan…
sharwell Mar 1, 2013
05d23bb
Remove handle when dispose is called for the first time
jbialobr Mar 1, 2013
d2d5b41
Revert "Remove handle when dispose is called for the first time"
jbialobr Mar 1, 2013
bbf738f
Merge pull request #1 from sharwell/jbialobr_vNext
jbialobr Mar 1, 2013
3e4cb0f
Handle the case when IsInvalid will be called for the first time afte…
jbialobr Mar 1, 2013
be73756
Make sure handles get registered, and also clean up invalid handles
sharwell Mar 1, 2013
3715ec2
Unregister handle from finalizer either Dispose
jbialobr Mar 2, 2013
858f084
Make sure the debugger doesn't evaluate the SafeHandleBase.IsInvalid …
sharwell Mar 2, 2013
ab6c594
Safe and clearly documented global cleanup in SafeHandleBase
sharwell Mar 2, 2013
ccef7be
Update code for execution in a contrained execution region
sharwell Mar 2, 2013
093fca9
Add ReliabilityContract attributes.
jbialobr Mar 3, 2013
5ca8226
Revert "Add ReliabilityContract attributes."
jbialobr Mar 4, 2013
fb02cac
Revert "Unregister handle from finalizer either Dispose"
jbialobr Mar 4, 2013
3c02129
Merge branch 'pr/n2_sharwell' into vNext
jbialobr Mar 4, 2013
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add ReliabilityContract attributes.
  • Loading branch information
jbialobr committed Mar 3, 2013
commit 093fca927c574e57384179ccc762415bf878444b
4 changes: 3 additions & 1 deletion LibGit2Sharp/Core/Handles/SafeHandleBase.cs
Original file line number F2AF Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Diagnostics;
using System.Runtime.ConstrainedExecution;
using System.Globalization;
using System.Runtime.InteropServices;
using System.Threading;
Expand All @@ -13,7 +14,7 @@ internal abstract class SafeHandleBase : SafeHandle
#endif

/// <summary>
/// This is set to non-zero when <see cref="NativeMethods.AddHandle"/> has
/// This is set to 1 when <see cref="NativeMethods.AddHandle"/> has
/// been called for this handle.
/// </summary>
private int registered = 0;
Expand Down Expand Up @@ -53,6 +54,7 @@ protected override void Dispose(bool disposing)
UnregisterHandle();
}

[ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
private void UnregisterHandle()
{
int n = Interlocked.Decrement(ref registered);
Expand Down
2 changes: 2 additions & 0 deletions LibGit2Sharp/Core/NativeMethods.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,13 @@ public LibraryLifetimeObject()
}
}

[ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
internal static void AddHandle()
{
Interlocked.Increment(ref handlesCount);
}

[ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
internal static void RemoveHandle()
{
int hCount = Interlocked.Decrement(ref handlesCount);
Expand Down
0