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)
...
@@ -420,6 +420,26 @@ void *vlc_threadvar_get (vlc_threadvar_t key)
return
value
;
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 ***/
/*** Threads ***/
static
DWORD
thread_key
;
static
DWORD
thread_key
;
...
@@ -451,30 +471,6 @@ static bool isCancelled(void)
...
@@ -451,30 +471,6 @@ static bool isCancelled(void)
}
}
#endif
#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
)
static
unsigned
__stdcall
vlc_entry
(
void
*
p
)
{
{
struct
vlc_thread
*
th
=
p
;
struct
vlc_thread
*
th
=
p
;
...
@@ -482,7 +478,10 @@ static unsigned __stdcall vlc_entry (void *p)
...
@@ -482,7 +478,10 @@ static unsigned __stdcall vlc_entry (void *p)
TlsSetValue
(
thread_key
,
th
);
TlsSetValue
(
thread_key
,
th
);
th
->
killable
=
true
;
th
->
killable
=
true
;
th
->
data
=
th
->
entry
(
th
->
data
);
th
->
data
=
th
->
entry
(
th
->
data
);
vlc_thread_cleanup
(
th
);
TlsSetValue
(
thread_key
,
NULL
);
if
(
th
->
id
==
NULL
)
/* Detached thread */
free
(
th
);
return
0
;
return
0
;
}
}
...
@@ -630,7 +629,9 @@ void vlc_testcancel (void)
...
@@ -630,7 +629,9 @@ void vlc_testcancel (void)
p
->
proc
(
p
->
data
);
p
->
proc
(
p
->
data
);
th
->
data
=
NULL
;
/* TODO: special value? */
th
->
data
=
NULL
;
/* TODO: special value? */
vlc_thread_cleanup
(
th
);
TlsSetValue
(
thread_key
,
NULL
);
if
(
th
->
id
==
NULL
)
/* Detached thread */
free
(
th
);
_endthreadex
(
0
);
_endthreadex
(
0
);
}
}
...
@@ -1039,6 +1040,10 @@ BOOL WINAPI DllMain (HINSTANCE hinstDll, DWORD fdwReason, LPVOID lpvReserved)
...
@@ -1039,6 +1040,10 @@ BOOL WINAPI DllMain (HINSTANCE hinstDll, DWORD fdwReason, LPVOID lpvReserved)
DeleteCriticalSection
(
&
clock_lock
);
DeleteCriticalSection
(
&
clock_lock
);
TlsFree
(
thread_key
);
TlsFree
(
thread_key
);
break
;
break
;
case
DLL_THREAD_DETACH
:
vlc_threadvars_cleanup
();
break
;
}
}
return
TRUE
;
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