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
6e2ed233
Commit
6e2ed233
authored
Oct 05, 2008
by
Rémi Denis-Courmont
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove slow and leaking var_AcquireMutex
parent
e3984284
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
0 additions
and
61 deletions
+0
-61
include/vlc_variables.h
include/vlc_variables.h
+0
-19
src/libvlccore.sym
src/libvlccore.sym
+0
-1
src/misc/threads.c
src/misc/threads.c
+0
-41
No files found.
include/vlc_variables.h
View file @
6e2ed233
...
...
@@ -133,25 +133,6 @@ VLC_EXPORT( int, __var_Get, ( vlc_object_t *, const char *, vlc_value_t * ) );
#define var_Command(a,b,c,d,e) __var_Command( VLC_OBJECT( a ), b, c, d, e )
VLC_EXPORT
(
int
,
__var_Command
,
(
vlc_object_t
*
,
const
char
*
,
const
char
*
,
const
char
*
,
char
**
)
);
VLC_EXPORT
(
vlc_mutex_t
*
,
var_AcquireMutex
,
(
const
char
*
)
LIBVLC_USED
);
#ifdef __GNUC__
static
__attribute__
((
unused
))
__attribute__
((
noinline
))
__attribute__
((
error
(
"variable mutex name leaks memory at run-time"
)))
const
char
*
nonconst_mutex_name
(
const
char
*
str
)
{
return
str
;
}
# define check_named_mutex( m ) \
(__builtin_constant_p(m) ? m : nonconst_mutex_name(m))
#else
# define check_named_mutex( m ) (m)
#endif
#define var_AcquireMutex( n ) var_AcquireMutex(check_named_mutex(n))
/**
* __var_Create() with automatic casting.
*/
...
...
src/libvlccore.sym
View file @
6e2ed233
...
...
@@ -411,7 +411,6 @@ utf8_scandir
utf8_stat
utf8_unlink
utf8_vfprintf
var_AcquireMutex
__var_AddCallback
__var_Change
__var_Command
...
...
src/misc/threads.c
View file @
6e2ed233
...
...
@@ -45,17 +45,6 @@
static
vlc_threadvar_t
cancel_key
;
#endif
static
struct
{
vlc_dictionary_t
list
;
vlc_mutex_t
lock
;
}
named_mutexes
=
{
{
0
,
NULL
,
},
#ifdef LIBVLC_USE_PTHREAD
PTHREAD_MUTEX_INITIALIZER
,
#endif
};
#ifdef HAVE_EXECINFO_H
# include <execinfo.h>
#endif
...
...
@@ -167,8 +156,6 @@ BOOL WINAPI DllMain (HINSTANCE hinstDll, DWORD fdwReason, LPVOID lpvReserved)
switch
(
fdwReason
)
{
case
DLL_PROCESS_ATTACH
:
vlc_dictionary_init
(
&
named_mutexes
.
list
,
0
);
vlc_mutex_init
(
&
named_mutexes
.
lock
);
vlc_mutex_init
(
&
super_mutex
);
vlc_threadvar_create
(
&
cancel_key
,
free
);
break
;
...
...
@@ -176,8 +163,6 @@ BOOL WINAPI DllMain (HINSTANCE hinstDll, DWORD fdwReason, LPVOID lpvReserved)
case
DLL_PROCESS_DETACH
:
vlc_threadvar_delete
(
&
cancel_key
);
vlc_mutex_destroy
(
&
super_mutex
);
vlc_mutex_destroy
(
&
named_mutexes
.
lock
);
vlc_dictionary_clear
(
&
named_mutexes
.
list
);
break
;
}
return
TRUE
;
...
...
@@ -1060,29 +1045,3 @@ void vlc_control_cancel (int cmd, ...)
va_end
(
ap
);
#endif
}
#undef var_AcquireMutex
/**
* Finds a process-wide mutex, creates it if needed, and locks it.
* Unlock with vlc_mutex_unlock().
* FIXME: This is very inefficient, this is not memory-safe and this leaks
* memory. Use static locks instead.
*/
vlc_mutex_t
*
var_AcquireMutex
(
const
char
*
name
)
{
vlc_mutex_t
*
lock
;
vlc_mutex_lock
(
&
named_mutexes
.
lock
);
lock
=
vlc_dictionary_value_for_key
(
&
named_mutexes
.
list
,
name
);
if
(
lock
==
kVLCDictionaryNotFound
)
{
lock
=
malloc
(
sizeof
(
*
lock
));
vlc_mutex_init
(
lock
);
vlc_dictionary_insert
(
&
named_mutexes
.
list
,
name
,
lock
);
}
vlc_mutex_unlock
(
&
named_mutexes
.
lock
);
vlc_mutex_lock
(
lock
);
return
lock
;
}
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