[vlc-devel] [PATCH 2/3] objects: allow using DumpStructure in other parts of the core

Steve Lhomme robux4 at ycbcr.xyz
Tue Mar 12 10:18:21 CET 2019


On 3/12/2019 9:33 AM, Thomas Guillem wrote:
>
> On Tue, Mar 12, 2019, at 09:25, Steve Lhomme wrote:
>> ---
>>   src/misc/objects.c   | 9 +++++----
>>   src/misc/variables.h | 1 +
>>   2 files changed, 6 insertions(+), 4 deletions(-)
>>
>> diff --git a/src/misc/objects.c b/src/misc/objects.c
>> index 481536d258..61318c951a 100644
>> --- a/src/misc/objects.c
>> +++ b/src/misc/objects.c
>> @@ -117,7 +117,7 @@ static void PrintObject(vlc_object_t *obj, FILE *output)
>>       vlc_restorecancel (canc);
>>   }
>>   
>> -static void DumpStructure(vlc_object_t *obj, FILE *output, unsigned
>> level)
>> +void DumpStructure(vlc_object_t *obj, FILE *output, unsigned level,
>> bool locked)
> I prefer adding a new function DumpStructureLocked than handling a new locked boolean.

In that case we just drop the boolean and the assert it would always 
call DumpStructureLocked() since in locked functions we don't check the 
assert. And the "external" (non recursive) call is done with a call 
around it.

For the leak the lock feature is useless, nothing is supposed to be 
alive anymore in libvlc_InternalDestroy()
>
>>   {
>>       PrintObject(obj, output);
>>   
>> @@ -129,9 +129,10 @@ static void DumpStructure(vlc_object_t *obj, FILE
>> *output, unsigned level)
>>   
>>       vlc_object_internals_t *priv;
>>   
>> -    vlc_mutex_assert(&tree_lock);
>> +    if (locked)
>> +        vlc_mutex_assert(&tree_lock);
>>       vlc_children_foreach(priv, vlc_internals(obj))
>> -        DumpStructure(vlc_externals(priv), output, level + 1);
>> +        DumpStructure(vlc_externals(priv), output, level + 1, locked);
>>   }
>>   
>>   /**
>> @@ -148,7 +149,7 @@ static int TreeCommand (vlc_object_t *obj, char const *cmd,
>>   
>>       flockfile(stdout);
>>       vlc_mutex_lock(&tree_lock);
>> -    DumpStructure(obj, stdout, 0);
>> +    DumpStructure(obj, stdout, 0, true);
>>       vlc_mutex_unlock(&tree_lock);
>>       funlockfile(stdout);
>>       return VLC_SUCCESS;
>> diff --git a/src/misc/variables.h b/src/misc/variables.h
>> index b850553687..10bf2db369 100644
>> --- a/src/misc/variables.h
>> +++ b/src/misc/variables.h
>> @@ -60,6 +60,7 @@ struct vlc_object_internals
>>   # define vlc_externals( priv ) ((vlc_object_t *)((priv) + 1))
>>   
>>   void DumpVariables(vlc_object_t *obj);
>> +void DumpStructure(vlc_object_t *obj, FILE *output, unsigned level,
>> bool locked);
>>   
>>   extern void var_DestroyAll( vlc_object_t * );
>>   
>> -- 
>> 2.17.1
>>
>> _______________________________________________
>> vlc-devel mailing list
>> To unsubscribe or modify your subscription options:
>> https://mailman.videolan.org/listinfo/vlc-devel
> _______________________________________________
> vlc-devel mailing list
> To unsubscribe or modify your subscription options:
> https://mailman.videolan.org/listinfo/vlc-devel



More information about the vlc-devel mailing list