Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
git2
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lvzhengyang
git2
Commits
81c9894f
Unverified
Commit
81c9894f
authored
May 09, 2018
by
Patrick Steinhardt
Committed by
GitHub
May 09, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #4645 from pks-t/pks/racy-init-deinit
global: adjust init count under lock
parents
6c2939d6
0933fdc5
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
10 deletions
+11
-10
src/global.c
+11
-10
No files found.
src/global.c
View file @
81c9894f
...
...
@@ -276,10 +276,10 @@ int git_libgit2_init(void)
{
int
ret
,
err
;
ret
=
git_atomic_inc
(
&
git__n_inits
);
if
((
err
=
pthread_mutex_lock
(
&
_init_mutex
))
!=
0
)
return
err
;
ret
=
git_atomic_inc
(
&
git__n_inits
);
err
=
pthread_once
(
&
_once_init
,
init_once
);
err
|=
pthread_mutex_unlock
(
&
_init_mutex
);
...
...
@@ -293,13 +293,13 @@ int git_libgit2_shutdown(void)
{
void
*
ptr
=
NULL
;
pthread_once_t
new_once
=
PTHREAD_ONCE_INIT
;
int
ret
;
int
error
,
ret
;
if
((
ret
=
git_atomic_dec
(
&
git__n_inits
))
!=
0
)
return
ret
;
if
((
error
=
pthread_mutex_lock
(
&
_init_mutex
))
!=
0
)
return
error
;
if
((
ret
=
pthread_mutex_lock
(
&
_init_mutex
))
!=
0
)
return
re
t
;
if
((
ret
=
git_atomic_dec
(
&
git__n_inits
))
!=
0
)
goto
ou
t
;
/* Shut down any subsystems that have global state */
shutdown_common
();
...
...
@@ -314,10 +314,11 @@ int git_libgit2_shutdown(void)
git_mutex_free
(
&
git__mwindow_mutex
);
_once_init
=
new_once
;
if
((
ret
=
pthread_mutex_unlock
(
&
_init_mutex
))
!=
0
)
return
ret
;
out:
if
((
error
=
pthread_mutex_unlock
(
&
_init_mutex
))
!=
0
)
return
error
;
return
0
;
return
ret
;
}
git_global_st
*
git__global_state
(
void
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment