Ticket #6166: 0002-Add-net_stack_cleanup.patch

File 0002-Add-net_stack_cleanup.patch, 1.8 KB (added by andreasf, 14 years ago)

proposed patch: add net_stack_cleanup()

  • headers/private/kernel/boot/net/NetStack.h

    From 89c8a3243f11aa19d3240d50a722c11a6bc1c4e0 Mon Sep 17 00:00:00 2001
    From: Andreas Faerber <andreas.faerber@web.de>
    Date: Sun, 13 Jun 2010 16:55:53 +0200
    Subject: [PATCH 2/3] Add net_stack_cleanup()
    
    Add a cleanup function net_stack_cleanup() that calls a new NetStack::ShutDown() method.
    Make sure this method works even if the network stack was never initialized.
    ---
     headers/private/kernel/boot/net/NetStack.h |    2 ++
     src/system/boot/loader/net/NetStack.cpp    |   19 +++++++++++++++++++
     2 files changed, 21 insertions(+), 0 deletions(-)
    
    diff --git a/headers/private/kernel/boot/net/NetStack.h b/headers/private/kernel/boot/net/NetStack.h
    index e2baeaa..40c554b 100644
    a b private:  
    2525public:
    2626    static status_t CreateDefault();
    2727    static NetStack *Default();
     28    static status_t ShutDown();
    2829
    2930    status_t AddEthernetInterface(EthernetInterface *interface);
    3031
    private:  
    5051// afterwards, which is supposed to add network interfaces.
    5152status_t net_stack_init();
    5253status_t platform_net_stack_init();
     54status_t net_stack_cleanup();
    5355
    5456
    5557#endif  // _BOOT_NET_STACK_H
  • src/system/boot/loader/net/NetStack.cpp

    diff --git a/src/system/boot/loader/net/NetStack.cpp b/src/system/boot/loader/net/NetStack.cpp
    index 7db3de0..65f4808 100644
    a b NetStack::Default()  
    104104    return sNetStack;
    105105}
    106106
     107
     108status_t
     109NetStack::ShutDown()
     110{
     111    if (sNetStack != NULL) {
     112        delete sNetStack;
     113        sNetStack = NULL;
     114    }
     115
     116    return B_OK;
     117}
     118
     119
    107120// AddEthernetInterface
    108121status_t
    109122NetStack::AddEthernetInterface(EthernetInterface *interface)
    net_stack_init()  
    139152    return platform_net_stack_init();
    140153}
    141154
     155
     156status_t
     157net_stack_cleanup()
     158{
     159    return NetStack::ShutDown();
     160}