Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc-gpu
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-gpu
Commits
523ef308
Commit
523ef308
authored
May 28, 2008
by
Rémi Denis-Courmont
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
The totally dumb reference checker
parent
1746fdda
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
68 additions
and
0 deletions
+68
-0
src/libvlc.h
src/libvlc.h
+5
-0
src/misc/objects.c
src/misc/objects.c
+55
-0
src/misc/variables.c
src/misc/variables.c
+8
-0
No files found.
src/libvlc.h
View file @
523ef308
...
...
@@ -46,6 +46,11 @@ void system_End ( libvlc_int_t * );
int
vlc_threads_init
(
void
);
void
vlc_threads_end
(
void
);
vlc_object_t
*
vlc_threadobj
(
void
);
#ifndef NDEBUG
void
vlc_refcheck
(
vlc_object_t
*
obj
);
#else
# define vlc_refcheck( obj ) (void)0
#endif
/*
* CPU capabilities
...
...
src/misc/objects.c
View file @
523ef308
...
...
@@ -1469,3 +1469,58 @@ static void ListChildren( vlc_list_t *p_list, vlc_object_t *p_this, int i_type )
ListChildren
(
p_list
,
p_tmp
,
i_type
);
}
}
#ifndef NDEBUG
void
vlc_refcheck
(
vlc_object_t
*
obj
)
{
static
unsigned
errors
=
0
;
vlc_object_t
*
caller
=
vlc_threadobj
();
vlc_object_internals_t
*
priv
=
vlc_internals
(
obj
);
int
refs
;
if
(
errors
>
100
)
return
;
if
(
!
caller
)
return
;
/* main thread, not sure how to handle it */
/* An object can always access itself without reference! */
if
(
caller
==
obj
)
return
;
/* The calling thread is younger than the object.
* Access could be valid, we would need more accounting. */
if
(
caller
->
i_object_id
>
obj
->
i_object_id
)
return
;
vlc_spin_lock
(
&
priv
->
ref_spin
);
refs
=
priv
->
i_refcount
;
vlc_spin_unlock
(
&
priv
->
ref_spin
);
/* Object has more than one reference.
* The current thread could be holding a valid reference. */
if
(
refs
>
1
)
return
;
/* The parent of an object normally holds the unique reference.
* As not all objects are threads, it could also be an ancestor. */
vlc_mutex_lock
(
&
structure_lock
);
for
(
vlc_object_t
*
cur
=
obj
;
cur
!=
NULL
;
cur
=
cur
->
p_parent
)
if
(
cur
==
caller
)
{
vlc_mutex_unlock
(
&
structure_lock
);
return
;
}
vlc_mutex_unlock
(
&
structure_lock
);
#if 1
if
(
caller
->
i_object_type
==
VLC_OBJECT_PLAYLIST
)
return
;
/* Playlist is too clever, or hopelessly broken. */
#endif
msg_Err
(
caller
,
"This thread is accessing..."
);
msg_Err
(
obj
,
"...this object in a suspicious manner."
);
if
(
++
errors
==
100
)
msg_Err
(
caller
,
"Too many reference errors"
);
}
#endif
src/misc/variables.c
View file @
523ef308
...
...
@@ -168,6 +168,7 @@ int __var_Create( vlc_object_t *p_this, const char *psz_name, int i_type )
static
vlc_list_t
dummy_null_list
=
{
0
,
NULL
,
NULL
};
vlc_object_internals_t
*
p_priv
=
vlc_internals
(
p_this
);
vlc_refcheck
(
p_this
);
vlc_mutex_lock
(
&
p_priv
->
var_lock
);
/* FIXME: if the variable already exists, we don't duplicate it. But we
...
...
@@ -331,6 +332,7 @@ int __var_Destroy( vlc_object_t *p_this, const char *psz_name )
variable_t
*
p_var
;
vlc_object_internals_t
*
p_priv
=
vlc_internals
(
p_this
);
vlc_refcheck
(
p_this
);
vlc_mutex_lock
(
&
p_priv
->
var_lock
);
i_var
=
GetUnused
(
p_this
,
psz_name
);
...
...
@@ -407,6 +409,7 @@ int __var_Change( vlc_object_t *p_this, const char *psz_name,
vlc_value_t
oldval
;
vlc_object_internals_t
*
p_priv
=
vlc_internals
(
p_this
);
vlc_refcheck
(
p_this
);
vlc_mutex_lock
(
&
p_priv
->
var_lock
);
i_var
=
Lookup
(
p_priv
->
p_vars
,
p_priv
->
i_vars
,
psz_name
);
...
...
@@ -759,6 +762,7 @@ int __var_Set( vlc_object_t *p_this, const char *psz_name, vlc_value_t val )
vlc_value_t
oldval
;
vlc_object_internals_t
*
p_priv
=
vlc_internals
(
p_this
);
vlc_refcheck
(
p_this
);
vlc_mutex_lock
(
&
p_priv
->
var_lock
);
i_var
=
GetUnused
(
p_this
,
psz_name
);
...
...
@@ -836,6 +840,7 @@ int __var_Get( vlc_object_t *p_this, const char *psz_name, vlc_value_t *p_val )
variable_t
*
p_var
;
vlc_object_internals_t
*
p_priv
=
vlc_internals
(
p_this
);
vlc_refcheck
(
p_this
);
vlc_mutex_lock
(
&
p_priv
->
var_lock
);
i_var
=
Lookup
(
p_priv
->
p_vars
,
p_priv
->
i_vars
,
psz_name
);
...
...
@@ -902,6 +907,7 @@ int __var_AddCallback( vlc_object_t *p_this, const char *psz_name,
callback_entry_t
entry
;
vlc_object_internals_t
*
p_priv
=
vlc_internals
(
p_this
);
vlc_refcheck
(
p_this
);
entry
.
pf_callback
=
pf_callback
;
entry
.
p_data
=
p_data
;
...
...
@@ -939,6 +945,7 @@ int __var_DelCallback( vlc_object_t *p_this, const char *psz_name,
variable_t
*
p_var
;
vlc_object_internals_t
*
p_priv
=
vlc_internals
(
p_this
);
vlc_refcheck
(
p_this
);
vlc_mutex_lock
(
&
p_priv
->
var_lock
);
i_var
=
GetUnused
(
p_this
,
psz_name
);
...
...
@@ -1575,6 +1582,7 @@ int __var_Command( vlc_object_t *p_this, const char *psz_name,
return
VLC_ENOOBJ
;
}
vlc_refcheck
(
p_this
);
i_type
=
var_Type
(
p_obj
,
psz_cmd
);
if
(
!
(
i_type
&
VLC_VAR_ISCOMMAND
)
)
{
...
...
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