[gPXE-devel] [PATCH] [settings] Unregister the children when unregistering the parent

Joshua Oreman oremanj at rwcr.net
Sat Jul 17 15:13:33 EDT 2010


2010/7/14 Joshua Oreman <oremanj at rwcr.net>:
> 2010/7/14 Piotr Jaroszyński <p.jaroszynski at gmail.com>:
>> I have come up with this change when debugging netdevices not being
>> free()d on shutdown(). The dhcppkt->settings registered in
>> dhcp_request_rx() with netdev's settings as parent are not unregistered
>> anywhere. That makes the netdevice's refcnt to stay >=0.
>>
>> Apart from that it also just seems to make sense to not leave parentless
>> children settings around.
>
> Looks good to me. Comments from anyone? If not I'll apply in 24 hours.

Applied. Thanks, and sorry it took longer than it should've!

http://git.etherboot.org/?p=gpxe.git;a=commit;h=eabe6acdedcc2248e0c323d4750968fea7b59caa

-- Josh

>
> -- Josh
>
>> ---
>>  src/core/settings.c |    8 +++++++-
>>  1 files changed, 7 insertions(+), 1 deletions(-)
>>
>> diff --git a/src/core/settings.c b/src/core/settings.c
>> index 963bfd5..93ed2ea 100644
>> --- a/src/core/settings.c
>> +++ b/src/core/settings.c
>> @@ -459,15 +459,21 @@ int register_settings ( struct settings *settings, struct settings *parent ) {
>>  * @v settings         Settings block
>>  */
>>  void unregister_settings ( struct settings *settings ) {
>> +       struct settings *child;
>> +       struct settings *tmp;
>> +
>> +       list_for_each_entry_safe ( child, tmp, &settings->children, siblings ) {
>> +               unregister_settings ( child );
>> +       }
>>
>>        DBGC ( settings, "Settings %p (\"%s\") unregistered\n",
>>               settings, settings_name ( settings ) );
>>
>>        /* Remove from list of settings */
>> -       ref_put ( settings->refcnt );
>>        ref_put ( settings->parent->refcnt );
>>        settings->parent = NULL;
>>        list_del ( &settings->siblings );
>> +       ref_put ( settings->refcnt );
>>
>>        /* Apply potentially-updated settings */
>>        apply_settings();
>> --
>> 1.7.1
>>
>> _______________________________________________
>> gPXE-devel mailing list
>> gPXE-devel at etherboot.org
>> http://etherboot.org/mailman/listinfo/gpxe-devel
>>
>


More information about the gPXE-devel mailing list