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
c5b09080
Commit
c5b09080
authored
Apr 15, 2009
by
Rémi Denis-Courmont
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Revert "Win32: use the destructor function for TLS (fixes #2398)"
This reverts commit
3cda36f4
.
parent
7156d7e3
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
71 deletions
+12
-71
include/vlc_threads.h
include/vlc_threads.h
+1
-1
src/misc/threads.c
src/misc/threads.c
+11
-70
No files found.
include/vlc_threads.h
View file @
c5b09080
...
@@ -128,7 +128,7 @@ typedef struct
...
@@ -128,7 +128,7 @@ typedef struct
#define VLC_STATIC_MUTEX { 0, }
#define VLC_STATIC_MUTEX { 0, }
typedef
HANDLE
vlc_cond_t
;
typedef
HANDLE
vlc_cond_t
;
typedef
struct
vlc_threadvar
*
vlc_threadvar_t
;
typedef
DWORD
vlc_threadvar_t
;
#endif
#endif
...
...
src/misc/threads.c
View file @
c5b09080
...
@@ -244,8 +244,7 @@ DWORD WaitForMultipleObjectsEx (DWORD nCount, const HANDLE *lpHandles,
...
@@ -244,8 +244,7 @@ DWORD WaitForMultipleObjectsEx (DWORD nCount, const HANDLE *lpHandles,
#endif
#endif
#ifdef WIN32
#ifdef WIN32
static
vlc_mutex_t
super_mutex
,
tls_mutex
;
static
vlc_mutex_t
super_mutex
;
static
struct
vlc_threadvar
*
tls_list
=
NULL
;
BOOL
WINAPI
DllMain
(
HINSTANCE
hinstDll
,
DWORD
fdwReason
,
LPVOID
lpvReserved
)
BOOL
WINAPI
DllMain
(
HINSTANCE
hinstDll
,
DWORD
fdwReason
,
LPVOID
lpvReserved
)
{
{
...
@@ -256,14 +255,11 @@ BOOL WINAPI DllMain (HINSTANCE hinstDll, DWORD fdwReason, LPVOID lpvReserved)
...
@@ -256,14 +255,11 @@ BOOL WINAPI DllMain (HINSTANCE hinstDll, DWORD fdwReason, LPVOID lpvReserved)
{
{
case
DLL_PROCESS_ATTACH
:
case
DLL_PROCESS_ATTACH
:
vlc_mutex_init
(
&
super_mutex
);
vlc_mutex_init
(
&
super_mutex
);
vlc_mutex_init
(
&
tls_mutex
);
vlc_threadvar_create
(
&
cancel_key
,
free
);
vlc_threadvar_create
(
&
cancel_key
,
free
);
break
;
break
;
case
DLL_PROCESS_DETACH
:
case
DLL_PROCESS_DETACH
:
vlc_threadvar_delete
(
&
cancel_key
);
vlc_threadvar_delete
(
&
cancel_key
);
assert
(
tls_list
==
NULL
);
vlc_mutex_destroy
(
&
tls_mutex
);
vlc_mutex_destroy
(
&
super_mutex
);
vlc_mutex_destroy
(
&
super_mutex
);
break
;
break
;
}
}
...
@@ -663,83 +659,31 @@ int vlc_cond_timedwait (vlc_cond_t *p_condvar, vlc_mutex_t *p_mutex,
...
@@ -663,83 +659,31 @@ int vlc_cond_timedwait (vlc_cond_t *p_condvar, vlc_mutex_t *p_mutex,
#endif
#endif
}
}
#if defined (LIBVLC_USE_PTHREAD)
#elif defined (WIN32)
struct
vlc_threadvar
{
DWORD
handle
;
void
(
*
cleanup
)
(
void
*
);
struct
vlc_threadvar
*
prev
,
*
next
;
};
static
void
vlc_threadvar_cleanup
(
void
)
{
struct
vlc_threadvar
*
p
;
vlc_mutex_lock
(
&
tls_mutex
);
for
(
p
=
tls_list
;
p
!=
NULL
;
p
=
p
->
next
)
{
void
*
value
=
TlsGetValue
(
p
->
handle
);
if
(
value
)
p
->
cleanup
(
value
);
}
vlc_mutex_unlock
(
&
tls_mutex
);
}
#endif
/*****************************************************************************
/*****************************************************************************
* vlc_tls_create: create a thread-local variable
* vlc_tls_create: create a thread-local variable
*****************************************************************************/
*****************************************************************************/
int
vlc_threadvar_create
(
vlc_threadvar_t
*
p_tls
,
void
(
*
destr
)
(
void
*
)
)
int
vlc_threadvar_create
(
vlc_threadvar_t
*
p_tls
,
void
(
*
destr
)
(
void
*
)
)
{
{
#if defined( LIBVLC_USE_PTHREAD )
int
i_ret
;
return
pthread_key_create
(
p_tls
,
destr
);
#if defined( LIBVLC_USE_PTHREAD )
i_ret
=
pthread_key_create
(
p_tls
,
destr
);
#elif defined( WIN32 )
#elif defined( WIN32 )
struct
vlc_threadvar
*
tls
=
malloc
(
sizeof
(
*
tls
));
/* FIXME: remember/use the destr() callback and stop leaking whatever */
if
(
tls
==
NULL
)
*
p_tls
=
TlsAlloc
();
return
ENOMEM
;
i_ret
=
(
*
p_tls
==
TLS_OUT_OF_INDEXES
)
?
EAGAIN
:
0
;
tls
->
handle
=
TlsAlloc
();
if
(
tls
->
handle
==
TLS_OUT_OF_INDEXES
)
{
free
(
tls
);
return
EAGAIN
;
}
tls
->
cleanup
=
destr
;
tls
->
prev
=
NULL
;
vlc_mutex_lock
(
&
tls_mutex
);
tls
->
next
=
tls_list
;
if
(
tls_list
)
tls_list
->
prev
=
tls
;
tls_list
=
tls
;
vlc_mutex_unlock
(
&
tls_mutex
);
*
p_tls
=
tls
;
return
0
;
#else
#else
# error Unimplemented!
# error Unimplemented!
#endif
#endif
return
i_ret
;
}
}
void
vlc_threadvar_delete
(
vlc_threadvar_t
*
p_tls
)
void
vlc_threadvar_delete
(
vlc_threadvar_t
*
p_tls
)
{
{
#if defined( LIBVLC_USE_PTHREAD )
#if defined( LIBVLC_USE_PTHREAD )
pthread_key_delete
(
*
p_tls
);
pthread_key_delete
(
*
p_tls
);
#elif defined( WIN32 )
#elif defined( WIN32 )
struct
vlc_threadvar
*
tls
=
*
p_tls
;
TlsFree
(
*
p_tls
);
TlsFree
(
tls
->
handle
);
vlc_mutex_lock
(
&
tls_mutex
);
if
(
tls
->
prev
)
tls
->
prev
->
next
=
tls
->
next
;
if
(
tls
->
next
)
tls
->
next
->
prev
=
tls
->
prev
;
vlc_mutex_unlock
(
&
tls_mutex
);
free
(
tls
);
#else
#else
# error Unimplemented!
# error Unimplemented!
#endif
#endif
...
@@ -756,7 +700,7 @@ int vlc_threadvar_set (vlc_threadvar_t key, void *value)
...
@@ -756,7 +700,7 @@ int vlc_threadvar_set (vlc_threadvar_t key, void *value)
#if defined(LIBVLC_USE_PTHREAD)
#if defined(LIBVLC_USE_PTHREAD)
return
pthread_setspecific
(
key
,
value
);
return
pthread_setspecific
(
key
,
value
);
#elif defined( UNDER_CE ) || defined( WIN32 )
#elif defined( UNDER_CE ) || defined( WIN32 )
return
TlsSetValue
(
key
->
handle
,
value
)
?
ENOMEM
:
0
;
return
TlsSetValue
(
key
,
p_
value
)
?
ENOMEM
:
0
;
#else
#else
# error Unimplemented!
# error Unimplemented!
#endif
#endif
...
@@ -773,7 +717,7 @@ void *vlc_threadvar_get (vlc_threadvar_t key)
...
@@ -773,7 +717,7 @@ void *vlc_threadvar_get (vlc_threadvar_t key)
#if defined(LIBVLC_USE_PTHREAD)
#if defined(LIBVLC_USE_PTHREAD)
return
pthread_getspecific
(
key
);
return
pthread_getspecific
(
key
);
#elif defined( UNDER_CE ) || defined( WIN32 )
#elif defined( UNDER_CE ) || defined( WIN32 )
return
TlsGetValue
(
key
->
handle
);
return
TlsGetValue
(
key
);
#else
#else
# error Unimplemented!
# error Unimplemented!
#endif
#endif
...
@@ -791,7 +735,6 @@ static unsigned __stdcall vlc_entry (void *data)
...
@@ -791,7 +735,6 @@ static unsigned __stdcall vlc_entry (void *data)
vlc_threadvar_set
(
cancel_key
,
&
cancel_data
);
vlc_threadvar_set
(
cancel_key
,
&
cancel_data
);
self
->
data
=
self
->
entry
(
self
->
data
);
self
->
data
=
self
->
entry
(
self
->
data
);
vlc_threadvar_cleanup
();
return
0
;
return
0
;
}
}
#endif
#endif
...
@@ -1080,10 +1023,8 @@ void vlc_testcancel (void)
...
@@ -1080,10 +1023,8 @@ void vlc_testcancel (void)
# if defined (LIBVLC_USE_PTHREAD)
# if defined (LIBVLC_USE_PTHREAD)
pthread_exit
(
PTHREAD_CANCELLED
);
pthread_exit
(
PTHREAD_CANCELLED
);
# elif defined (UNDER_CE)
# elif defined (UNDER_CE)
vlc_threadvar_cleanup
();
ExitThread
(
0
);
ExitThread
(
0
);
# elif defined (WIN32)
# elif defined (WIN32)
vlc_threadvar_cleanup
();
_endthread
();
_endthread
();
# else
# else
# error Not implemented!
# error Not implemented!
...
...
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