Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Redmine
Redmine
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
videolan
vlc
Commits
2a6f4315
Commit
2a6f4315
authored
Jun 28, 2015
by
Rémi Denis-Courmont
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
win32: clean thread-local storage also on non-LibVLC threads
parent
f3d4fe1e
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
31 additions
and
26 deletions
+31
-26
src/win32/thread.c
src/win32/thread.c
+31
-26
No files found.
src/win32/thread.c
View file @
2a6f4315
...
...
@@ -420,6 +420,26 @@ void *vlc_threadvar_get (vlc_threadvar_t key)
return
value
;
}
static
void
vlc_threadvars_cleanup
(
void
)
{
vlc_threadvar_t
key
;
retry:
/* TODO: use RW lock or something similar */
vlc_mutex_lock
(
&
super_mutex
);
for
(
key
=
vlc_threadvar_last
;
key
!=
NULL
;
key
=
key
->
prev
)
{
void
*
value
=
vlc_threadvar_get
(
key
);
if
(
value
!=
NULL
&&
key
->
destroy
!=
NULL
)
{
vlc_mutex_unlock
(
&
super_mutex
);
vlc_threadvar_set
(
key
,
NULL
);
key
->
destroy
(
value
);
goto
retry
;
}
}
vlc_mutex_unlock
(
&
super_mutex
);
}
/*** Threads ***/
static
DWORD
thread_key
;
...
...
@@ -451,30 +471,6 @@ static bool isCancelled(void)
}
#endif
static
void
vlc_thread_cleanup
(
struct
vlc_thread
*
th
)
{
vlc_threadvar_t
key
;
retry:
/* TODO: use RW lock or something similar */
vlc_mutex_lock
(
&
super_mutex
);
for
(
key
=
vlc_threadvar_last
;
key
!=
NULL
;
key
=
key
->
prev
)
{
void
*
value
=
vlc_threadvar_get
(
key
);
if
(
value
!=
NULL
&&
key
->
destroy
!=
NULL
)
{
vlc_mutex_unlock
(
&
super_mutex
);
vlc_threadvar_set
(
key
,
NULL
);
key
->
destroy
(
value
);
goto
retry
;
}
}
vlc_mutex_unlock
(
&
super_mutex
);
if
(
th
->
id
==
NULL
)
/* Detached thread */
free
(
th
);
}
static
unsigned
__stdcall
vlc_entry
(
void
*
p
)
{
struct
vlc_thread
*
th
=
p
;
...
...
@@ -482,7 +478,10 @@ static unsigned __stdcall vlc_entry (void *p)
TlsSetValue
(
thread_key
,
th
);
th
->
killable
=
true
;
th
->
data
=
th
->
entry
(
th
->
data
);
vlc_thread_cleanup
(
th
);
TlsSetValue
(
thread_key
,
NULL
);
if
(
th
->
id
==
NULL
)
/* Detached thread */
free
(
th
);
return
0
;
}
...
...
@@ -630,7 +629,9 @@ void vlc_testcancel (void)
p
->
proc
(
p
->
data
);
th
->
data
=
NULL
;
/* TODO: special value? */
vlc_thread_cleanup
(
th
);
TlsSetValue
(
thread_key
,
NULL
);
if
(
th
->
id
==
NULL
)
/* Detached thread */
free
(
th
);
_endthreadex
(
0
);
}
...
...
@@ -1039,6 +1040,10 @@ BOOL WINAPI DllMain (HINSTANCE hinstDll, DWORD fdwReason, LPVOID lpvReserved)
DeleteCriticalSection
(
&
clock_lock
);
TlsFree
(
thread_key
);
break
;
case
DLL_THREAD_DETACH
:
vlc_threadvars_cleanup
();
break
;
}
return
TRUE
;
}
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