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
107958d7
Commit
107958d7
authored
Mar 04, 2015
by
Carlos Martín Nieto
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'tls_data'
parents
814d86bf
8e851c1e
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
37 additions
and
9 deletions
+37
-9
src/global.c
+37
-8
tests/main.c
+0
-1
No files found.
src/global.c
View file @
107958d7
...
...
@@ -36,16 +36,25 @@ void git__on_shutdown(git_global_shutdown_fn callback)
git__shutdown_callbacks
[
count
-
1
]
=
callback
;
}
static
void
git__global_state_cleanup
(
git_global_st
*
st
)
{
if
(
!
st
)
return
;
git__free
(
st
->
error_t
.
message
);
st
->
error_t
.
message
=
NULL
;
}
static
void
git__shutdown
(
void
)
{
int
pos
;
/* Shutdown subsystems that have registered */
for
(
pos
=
git_atomic_get
(
&
git__n_shutdown_callbacks
);
pos
>
0
;
pos
=
git_atomic_dec
(
&
git__n_shutdown_callbacks
))
{
git_global_shutdown_fn
cb
=
git__swap
(
git__shutdown_callbacks
[
pos
-
1
],
NULL
);
if
(
cb
!=
NULL
)
cb
();
}
}
#if defined(GIT_THREADS) && defined(GIT_SSL)
...
...
@@ -214,8 +223,14 @@ int git_libgit2_init(void)
static
void
synchronized_threads_shutdown
(
void
)
{
void
*
ptr
;
/* Shut down any subsystems that have global state */
git__shutdown
();
ptr
=
TlsGetValue
(
_tls_index
);
git__global_state_cleanup
(
ptr
);
TlsFree
(
_tls_index
);
git_mutex_free
(
&
git__mwindow_mutex
);
}
...
...
@@ -255,6 +270,17 @@ git_global_st *git__global_state(void)
return
ptr
;
}
BOOL
WINAPI
DllMain
(
HINSTANCE
dll
,
DWORD
reason
,
LPVOID
reserved
)
{
if
(
reason
==
DLL_THREAD_DETACH
)
{
void
*
ptr
=
TlsGetValue
(
_tls_index
);
git__global_state_cleanup
(
ptr
);
git__free
(
ptr
);
}
return
TRUE
;
}
#elif defined(GIT_THREADS) && defined(_POSIX_THREADS)
static
pthread_key_t
_tls_key
;
...
...
@@ -263,9 +289,7 @@ int init_error = 0;
static
void
cb__free_status
(
void
*
st
)
{
git_global_st
*
state
=
(
git_global_st
*
)
st
;
git__free
(
state
->
error_t
.
message
);
git__global_state_cleanup
(
st
);
git__free
(
st
);
}
...
...
@@ -302,7 +326,7 @@ int git_libgit2_shutdown(void)
pthread_once_t
new_once
=
PTHREAD_ONCE_INIT
;
int
ret
;
if
((
ret
=
git_atomic_dec
(
&
git__n_inits
))
>
0
)
if
((
ret
=
git_atomic_dec
(
&
git__n_inits
))
!=
0
)
return
ret
;
/* Shut down any subsystems that have global state */
...
...
@@ -310,13 +334,15 @@ int git_libgit2_shutdown(void)
ptr
=
pthread_getspecific
(
_tls_key
);
pthread_setspecific
(
_tls_key
,
NULL
);
git__global_state_cleanup
(
ptr
);
git__free
(
ptr
);
pthread_key_delete
(
_tls_key
);
git_mutex_free
(
&
git__mwindow_mutex
);
_once_init
=
new_once
;
return
ret
;
return
0
;
}
git_global_st
*
git__global_state
(
void
)
...
...
@@ -358,10 +384,13 @@ int git_libgit2_shutdown(void)
int
ret
;
/* Shut down any subsystems that have global state */
if
(
ret
=
git_atomic_dec
(
&
git__n_inits
))
if
((
ret
=
git_atomic_dec
(
&
git__n_inits
))
!=
0
)
return
ret
;
git__shutdown
();
git__global_state_cleanup
(
&
__state
);
return
ret
;
return
0
;
}
git_global_st
*
git__global_state
(
void
)
...
...
tests/main.c
View file @
107958d7
...
...
@@ -20,7 +20,6 @@ int main(int argc, char *argv[])
clar_test_shutdown
();
giterr_clear
();
cl_global_trace_disable
();
git_libgit2_shutdown
();
...
...
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