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:
|
25 | 25 | public: |
26 | 26 | static status_t CreateDefault(); |
27 | 27 | static NetStack *Default(); |
| 28 | static status_t ShutDown(); |
28 | 29 | |
29 | 30 | status_t AddEthernetInterface(EthernetInterface *interface); |
30 | 31 | |
… |
… |
private:
|
50 | 51 | // afterwards, which is supposed to add network interfaces. |
51 | 52 | status_t net_stack_init(); |
52 | 53 | status_t platform_net_stack_init(); |
| 54 | status_t net_stack_cleanup(); |
53 | 55 | |
54 | 56 | |
55 | 57 | #endif // _BOOT_NET_STACK_H |
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()
|
104 | 104 | return sNetStack; |
105 | 105 | } |
106 | 106 | |
| 107 | |
| 108 | status_t |
| 109 | NetStack::ShutDown() |
| 110 | { |
| 111 | if (sNetStack != NULL) { |
| 112 | delete sNetStack; |
| 113 | sNetStack = NULL; |
| 114 | } |
| 115 | |
| 116 | return B_OK; |
| 117 | } |
| 118 | |
| 119 | |
107 | 120 | // AddEthernetInterface |
108 | 121 | status_t |
109 | 122 | NetStack::AddEthernetInterface(EthernetInterface *interface) |
… |
… |
net_stack_init()
|
139 | 152 | return platform_net_stack_init(); |
140 | 153 | } |
141 | 154 | |
| 155 | |
| 156 | status_t |
| 157 | net_stack_cleanup() |
| 158 | { |
| 159 | return NetStack::ShutDown(); |
| 160 | } |