diff --git a/headers/private/kernel/boot/net/UDP.h b/headers/private/kernel/boot/net/UDP.h index fd1bdd6495..2b587f49a4 100644 --- a/headers/private/kernel/boot/net/UDP.h +++ b/headers/private/kernel/boot/net/UDP.h @@ -52,6 +52,7 @@ public: uint16 Port() const { return fPort; } status_t Bind(ip_addr_t address, uint16 port); + void Detach(); status_t Send(ip_addr_t destinationAddress, uint16 destinationPort, ChainBuffer *buffer); diff --git a/src/system/boot/loader/net/UDP.cpp b/src/system/boot/loader/net/UDP.cpp index 10af060bc4..5c4adbdc35 100644 --- a/src/system/boot/loader/net/UDP.cpp +++ b/src/system/boot/loader/net/UDP.cpp @@ -175,6 +175,15 @@ UDPSocket::Bind(ip_addr_t address, uint16 port) } +void +UDPSocket::Detach() +{ + fUDPService = NULL; + // This will lead to subsequent methods returning B_NO_INIT +} + + + status_t UDPSocket::Send(ip_addr_t destinationAddress, uint16 destinationPort, ChainBuffer *buffer) @@ -264,6 +273,12 @@ UDPService::UDPService(IPService *ipService) UDPService::~UDPService() { + int count = fSockets.Count(); + for (int i = 0; i < count; i++) { + UDPSocket *socket = fSockets.ElementAt(i); + socket->Detach(); + } + if (fIPService != NULL) fIPService->UnregisterIPSubService(this); }