No longer crashes when deleting "certain" interfaces (couldn't reproduce the

crash in Qemu for some reason).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20397 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler 2007-03-20 19:15:31 +00:00
parent 44b5d72b5a
commit 1a38ebd28b
3 changed files with 17 additions and 8 deletions

View File

@ -539,7 +539,6 @@ interface_protocol_down(net_datalink_protocol *_protocol)
interface_protocol *protocol = (interface_protocol *)_protocol;
net_device_interface *deviceInterface =
((net_interface_private *)protocol->interface)->device_interface;
net_device *device = protocol->device;
// TODO: locking!
if (deviceInterface->up_count == 0)
@ -550,12 +549,7 @@ interface_protocol_down(net_datalink_protocol *_protocol)
if (deviceInterface->up_count > 0)
return;
device->flags &= ~IFF_UP;
protocol->device_module->down(protocol->device);
// make sure the reader thread is gone before shutting down the interface
status_t status;
wait_for_thread(deviceInterface->reader_thread, &status);
down_device_interface(deviceInterface);
}

View File

@ -160,7 +160,7 @@ delete_interface(net_interface_private *interface)
if ((interface->flags & IFF_UP) != 0) {
// the interface is still up - we need to change that before deleting it
interface->flags &= ~IFF_UP;
interface->device_interface->module->down(interface->device_interface->device);
down_device_interface(interface->device_interface);
}
put_device_interface(interface->device_interface);
@ -398,6 +398,20 @@ get_device_interface(const char *name)
}
void
down_device_interface(net_device_interface *interface)
{
net_device *device = interface->device;
device->flags &= ~IFF_UP;
interface->module->down(device);
// make sure the reader thread is gone before shutting down the interface
status_t status;
wait_for_thread(interface->reader_thread, &status);
}
// #pragma mark - devices

View File

@ -76,6 +76,7 @@ status_t list_device_interfaces(void *buffer, size_t size);
void put_device_interface(struct net_device_interface *interface);
struct net_device_interface *get_device_interface(uint32 index);
struct net_device_interface *get_device_interface(const char *name);
void down_device_interface(net_device_interface *interface);
// devices
status_t unregister_device_deframer(net_device *device);