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
f79f2b1f
Commit
f79f2b1f
authored
Oct 05, 2008
by
Rémi Denis-Courmont
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove vlc_threads_(init|end), fix thread-safety on Win32
parent
43b5fcef
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
23 additions
and
73 deletions
+23
-73
src/libvlc.c
src/libvlc.c
+0
-10
src/libvlc.h
src/libvlc.h
+0
-2
src/misc/threads.c
src/misc/threads.c
+23
-61
No files found.
src/libvlc.c
View file @
f79f2b1f
...
...
@@ -238,11 +238,6 @@ libvlc_int_t * libvlc_InternalCreate( void )
libvlc_priv_t
*
priv
;
char
*
psz_env
=
NULL
;
/* vlc_threads_init *must* be the first internal call! No other call is
* allowed before the thread system has been initialized. */
if
(
vlc_threads_init
())
return
NULL
;
/* Now that the thread system is initialized, we don't have much, but
* at least we have variables */
vlc_mutex_t
*
lock
=
var_AcquireMutex
(
"libvlc"
);
...
...
@@ -1161,11 +1156,6 @@ int libvlc_InternalDestroy( libvlc_int_t *p_libvlc )
vlc_object_release
(
p_libvlc
);
p_libvlc
=
NULL
;
/* Stop thread system: last one out please shut the door!
* The number of initializations of the thread system is counted, we
* can call this each time */
vlc_threads_end
();
return
VLC_SUCCESS
;
}
...
...
src/libvlc.h
View file @
f79f2b1f
...
...
@@ -45,8 +45,6 @@ void system_End ( libvlc_int_t * );
/*
* Threads subsystem
*/
int
vlc_threads_init
(
void
);
void
vlc_threads_end
(
void
);
/* Hopefully, no need to export this. There is a new thread API instead. */
void
vlc_thread_cancel
(
vlc_object_t
*
);
...
...
src/misc/threads.c
View file @
f79f2b1f
...
...
@@ -39,15 +39,8 @@
#endif
#include <signal.h>
/*****************************************************************************
* Global mutex for lazy initialization of the threads system
*****************************************************************************/
static
volatile
unsigned
i_initializations
=
0
;
#if defined( LIBVLC_USE_PTHREAD )
# include <sched.h>
static
pthread_mutex_t
once_mutex
=
PTHREAD_MUTEX_INITIALIZER
;
#else
static
vlc_threadvar_t
cancel_key
;
#endif
...
...
@@ -56,7 +49,12 @@ static struct
{
vlc_dictionary_t
list
;
vlc_mutex_t
lock
;
}
named_mutexes
;
}
named_mutexes
=
{
{
0
,
NULL
,
},
#ifdef LIBVLC_USE_PTHREAD
PTHREAD_MUTEX_INITIALIZER
,
#endif
};
#ifdef HAVE_EXECINFO_H
# include <execinfo.h>
...
...
@@ -158,65 +156,29 @@ typedef struct vlc_cancel_t
# define VLC_CANCEL_INIT { NULL, true, false }
#endif
/*****************************************************************************
* vlc_threads_init: initialize threads system
*****************************************************************************
* This function requires lazy initialization of a global lock in order to
* keep the library really thread-safe. Some architectures don't support this
* and thus do not guarantee the complete reentrancy.
*****************************************************************************/
int
vlc_threads_init
(
void
)
#ifdef WIN32
BOOL
WINAPI
DllMain
(
HINSTANCE
hinstDll
,
DWORD
fdwReason
,
LPVOID
lpvReserved
)
{
/* If we have lazy mutex initialization, use it. Otherwise, we just
* hope nothing wrong happens. */
#if defined( LIBVLC_USE_PTHREAD )
pthread_mutex_lock
(
&
once_mutex
);
#endif
(
void
)
hinstDll
;
(
void
)
lpvReserved
;
if
(
i_initializations
==
0
)
switch
(
fdwReason
)
{
vlc_dictionary_init
(
&
named_mutexes
.
list
,
0
);
vlc_mutex_init
(
&
named_mutexes
.
lock
);
#ifndef LIBVLC_USE_PTHREAD_CANCEL
vlc_threadvar_create
(
&
cancel_key
,
free
);
#endif
}
i_initializations
++
;
#if defined( LIBVLC_USE_PTHREAD )
pthread_mutex_unlock
(
&
once_mutex
);
#endif
return
VLC_SUCCESS
;
}
/*****************************************************************************
* vlc_threads_end: stop threads system
*****************************************************************************
* FIXME: This function is far from being threadsafe.
*****************************************************************************/
void
vlc_threads_end
(
void
)
{
#if defined( LIBVLC_USE_PTHREAD )
pthread_mutex_lock
(
&
once_mutex
);
#endif
assert
(
i_initializations
>
0
);
case
DLL_PROCESS_ATTACH
:
vlc_dictionary_init
(
&
named_mutexes
.
list
,
0
);
vlc_mutex_init
(
&
named_mutexes
.
lock
);
vlc_threadvar_create
(
&
cancel_key
,
free
);
break
;
if
(
i_initializations
==
1
)
{
#ifndef LIBVLC_USE_PTHREAD
vlc_threadvar_delete
(
&
cancel_key
);
#endif
vlc_mutex_destroy
(
&
named_mutexes
.
lock
);
vlc_dictionary_clear
(
&
named_mutexes
.
list
);
case
DLL_PROCESS_DETACH
:
vlc_threadvar_delete
(
&
cancel_key
);
vlc_mutex_destroy
(
&
named_mutexes
.
lock
);
vlc_dictionary_clear
(
&
named_mutexes
.
list
);
break
;
}
i_initializations
--
;
#if defined( LIBVLC_USE_PTHREAD )
pthread_mutex_unlock
(
&
once_mutex
);
#endif
return
TRUE
;
}
#endif
#if defined (__GLIBC__) && (__GLIBC_MINOR__ < 6)
/* This is not prototyped under glibc, though it exists. */
...
...
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