mirror of
https://git.proxmox.com/git/libgit2
synced 2025-05-08 18:08:11 +00:00
Merge pull request #2329 from anuraggup/fix_git_shutdown
Fix the issues in git_shutdown
This commit is contained in:
commit
ed476c236b
10
src/global.c
10
src/global.c
@ -23,7 +23,7 @@ static git_atomic git__n_inits;
|
|||||||
void git__on_shutdown(git_global_shutdown_fn callback)
|
void git__on_shutdown(git_global_shutdown_fn callback)
|
||||||
{
|
{
|
||||||
int count = git_atomic_inc(&git__n_shutdown_callbacks);
|
int count = git_atomic_inc(&git__n_shutdown_callbacks);
|
||||||
assert(count <= MAX_SHUTDOWN_CB);
|
assert(count <= MAX_SHUTDOWN_CB && count > 0);
|
||||||
git__shutdown_callbacks[count - 1] = callback;
|
git__shutdown_callbacks[count - 1] = callback;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -31,10 +31,12 @@ static void git__shutdown(void)
|
|||||||
{
|
{
|
||||||
int pos;
|
int pos;
|
||||||
|
|
||||||
while ((pos = git_atomic_dec(&git__n_shutdown_callbacks)) >= 0) {
|
for (pos = git_atomic_get(&git__n_shutdown_callbacks); pos > 0; pos = git_atomic_dec(&git__n_shutdown_callbacks)) {
|
||||||
if (git__shutdown_callbacks[pos])
|
git_global_shutdown_fn cb = git__swap(git__shutdown_callbacks[pos - 1], NULL);
|
||||||
git__shutdown_callbacks[pos]();
|
if (cb != NULL)
|
||||||
|
cb();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -90,6 +90,8 @@ void git_sysdir_global_shutdown(void)
|
|||||||
int i;
|
int i;
|
||||||
for (i = 0; i < GIT_SYSDIR__MAX; ++i)
|
for (i = 0; i < GIT_SYSDIR__MAX; ++i)
|
||||||
git_buf_free(&git_sysdir__dirs[i]);
|
git_buf_free(&git_sysdir__dirs[i]);
|
||||||
|
|
||||||
|
git_sysdir__dirs_shutdown_set = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int git_sysdir_check_selector(git_sysdir_t which)
|
static int git_sysdir_check_selector(git_sysdir_t which)
|
||||||
|
Loading…
Reference in New Issue
Block a user