Converted the "net_interfaces" mutex into a recursive locker, and
acquire it in Interface::SetDown().
This commit is contained in:
parent
afa494c44e
commit
8a6337d0f8
@ -79,7 +79,7 @@ struct AddressHashDefinition {
|
|||||||
typedef BOpenHashTable<AddressHashDefinition, true, false> AddressTable;
|
typedef BOpenHashTable<AddressHashDefinition, true, false> AddressTable;
|
||||||
|
|
||||||
|
|
||||||
static mutex sLock;
|
static recursive_lock sLock;
|
||||||
static InterfaceList sInterfaces;
|
static InterfaceList sInterfaces;
|
||||||
static mutex sHashLock;
|
static mutex sHashLock;
|
||||||
static AddressTable sAddressTable;
|
static AddressTable sAddressTable;
|
||||||
@ -91,7 +91,7 @@ static uint32 sInterfaceIndex;
|
|||||||
void
|
void
|
||||||
dump_interface_refs(void)
|
dump_interface_refs(void)
|
||||||
{
|
{
|
||||||
MutexLocker locker(sLock);
|
RecursiveLocker locker(sLock);
|
||||||
|
|
||||||
InterfaceList::Iterator iterator = sInterfaces.GetIterator();
|
InterfaceList::Iterator iterator = sInterfaces.GetIterator();
|
||||||
while (Interface* interface = iterator.Next()) {
|
while (Interface* interface = iterator.Next()) {
|
||||||
@ -933,6 +933,7 @@ Interface::SetDown()
|
|||||||
if ((flags & IFF_UP) == 0)
|
if ((flags & IFF_UP) == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
RecursiveLocker interfacesLocker(sLock);
|
||||||
RecursiveLocker locker(fLock);
|
RecursiveLocker locker(fLock);
|
||||||
|
|
||||||
DatalinkTable::Iterator iterator = fDatalinkTable.GetIterator();
|
DatalinkTable::Iterator iterator = fDatalinkTable.GetIterator();
|
||||||
@ -1173,7 +1174,7 @@ Interface::_ChangeAddress(RecursiveLocker& locker, InterfaceAddress* address,
|
|||||||
static struct Interface*
|
static struct Interface*
|
||||||
find_interface(const char* name)
|
find_interface(const char* name)
|
||||||
{
|
{
|
||||||
ASSERT_LOCKED_MUTEX(&sLock);
|
ASSERT_LOCKED_RECURSIVE(&sLock);
|
||||||
|
|
||||||
InterfaceList::Iterator iterator = sInterfaces.GetIterator();
|
InterfaceList::Iterator iterator = sInterfaces.GetIterator();
|
||||||
while (Interface* interface = iterator.Next()) {
|
while (Interface* interface = iterator.Next()) {
|
||||||
@ -1208,7 +1209,7 @@ status_t
|
|||||||
add_interface(const char* name, net_domain_private* domain,
|
add_interface(const char* name, net_domain_private* domain,
|
||||||
const ifaliasreq& request, net_device_interface* deviceInterface)
|
const ifaliasreq& request, net_device_interface* deviceInterface)
|
||||||
{
|
{
|
||||||
MutexLocker locker(sLock);
|
RecursiveLocker locker(sLock);
|
||||||
|
|
||||||
if (find_interface(name) != NULL)
|
if (find_interface(name) != NULL)
|
||||||
return B_NAME_IN_USE;
|
return B_NAME_IN_USE;
|
||||||
@ -1249,7 +1250,7 @@ remove_interface(Interface* interface)
|
|||||||
interface->SetDown();
|
interface->SetDown();
|
||||||
interface->RemoveAddresses();
|
interface->RemoveAddresses();
|
||||||
|
|
||||||
MutexLocker locker(sLock);
|
RecursiveLocker locker(sLock);
|
||||||
sInterfaces.Remove(interface);
|
sInterfaces.Remove(interface);
|
||||||
locker.Unlock();
|
locker.Unlock();
|
||||||
|
|
||||||
@ -1265,7 +1266,7 @@ remove_interface(Interface* interface)
|
|||||||
void
|
void
|
||||||
interface_removed_device_interface(net_device_interface* deviceInterface)
|
interface_removed_device_interface(net_device_interface* deviceInterface)
|
||||||
{
|
{
|
||||||
MutexLocker locker(sLock);
|
RecursiveLocker locker(sLock);
|
||||||
|
|
||||||
Interface* interface = find_interface(deviceInterface->device->name);
|
Interface* interface = find_interface(deviceInterface->device->name);
|
||||||
if (interface != NULL)
|
if (interface != NULL)
|
||||||
@ -1396,7 +1397,7 @@ update_interface_address(InterfaceAddress* interfaceAddress, int32 option,
|
|||||||
Interface*
|
Interface*
|
||||||
get_interface(net_domain* domain, uint32 index)
|
get_interface(net_domain* domain, uint32 index)
|
||||||
{
|
{
|
||||||
MutexLocker locker(sLock);
|
RecursiveLocker locker(sLock);
|
||||||
|
|
||||||
Interface* interface;
|
Interface* interface;
|
||||||
if (index == 0)
|
if (index == 0)
|
||||||
@ -1417,7 +1418,7 @@ get_interface(net_domain* domain, uint32 index)
|
|||||||
Interface*
|
Interface*
|
||||||
get_interface(net_domain* domain, const char* name)
|
get_interface(net_domain* domain, const char* name)
|
||||||
{
|
{
|
||||||
MutexLocker locker(sLock);
|
RecursiveLocker locker(sLock);
|
||||||
|
|
||||||
Interface* interface = find_interface(name);
|
Interface* interface = find_interface(name);
|
||||||
if (interface == NULL)
|
if (interface == NULL)
|
||||||
@ -1434,7 +1435,7 @@ get_interface(net_domain* domain, const char* name)
|
|||||||
Interface*
|
Interface*
|
||||||
get_interface_for_device(net_domain* domain, uint32 index)
|
get_interface_for_device(net_domain* domain, uint32 index)
|
||||||
{
|
{
|
||||||
MutexLocker locker(sLock);
|
RecursiveLocker locker(sLock);
|
||||||
|
|
||||||
InterfaceList::Iterator iterator = sInterfaces.GetIterator();
|
InterfaceList::Iterator iterator = sInterfaces.GetIterator();
|
||||||
while (Interface* interface = iterator.Next()) {
|
while (Interface* interface = iterator.Next()) {
|
||||||
@ -1460,7 +1461,7 @@ get_interface_for_link(net_domain* domain, const sockaddr* _linkAddress)
|
|||||||
{
|
{
|
||||||
sockaddr_dl& linkAddress = *(sockaddr_dl*)_linkAddress;
|
sockaddr_dl& linkAddress = *(sockaddr_dl*)_linkAddress;
|
||||||
|
|
||||||
MutexLocker locker(sLock);
|
RecursiveLocker locker(sLock);
|
||||||
|
|
||||||
InterfaceList::Iterator iterator = sInterfaces.GetIterator();
|
InterfaceList::Iterator iterator = sInterfaces.GetIterator();
|
||||||
while (Interface* interface = iterator.Next()) {
|
while (Interface* interface = iterator.Next()) {
|
||||||
@ -1506,7 +1507,7 @@ InterfaceAddress*
|
|||||||
get_interface_address_for_destination(net_domain* domain,
|
get_interface_address_for_destination(net_domain* domain,
|
||||||
const sockaddr* destination)
|
const sockaddr* destination)
|
||||||
{
|
{
|
||||||
MutexLocker locker(sLock);
|
RecursiveLocker locker(sLock);
|
||||||
|
|
||||||
InterfaceList::Iterator iterator = sInterfaces.GetIterator();
|
InterfaceList::Iterator iterator = sInterfaces.GetIterator();
|
||||||
while (Interface* interface = iterator.Next()) {
|
while (Interface* interface = iterator.Next()) {
|
||||||
@ -1533,7 +1534,7 @@ get_interface_address_for_link(net_domain* domain, const sockaddr* address,
|
|||||||
{
|
{
|
||||||
sockaddr_dl& linkAddress = *(sockaddr_dl*)address;
|
sockaddr_dl& linkAddress = *(sockaddr_dl*)address;
|
||||||
|
|
||||||
MutexLocker locker(sLock);
|
RecursiveLocker locker(sLock);
|
||||||
|
|
||||||
InterfaceList::Iterator iterator = sInterfaces.GetIterator();
|
InterfaceList::Iterator iterator = sInterfaces.GetIterator();
|
||||||
while (Interface* interface = iterator.Next()) {
|
while (Interface* interface = iterator.Next()) {
|
||||||
@ -1558,7 +1559,7 @@ get_interface_address_for_link(net_domain* domain, const sockaddr* address,
|
|||||||
uint32
|
uint32
|
||||||
count_interfaces()
|
count_interfaces()
|
||||||
{
|
{
|
||||||
MutexLocker locker(sLock);
|
RecursiveLocker locker(sLock);
|
||||||
|
|
||||||
return sInterfaces.Count();
|
return sInterfaces.Count();
|
||||||
}
|
}
|
||||||
@ -1571,7 +1572,7 @@ count_interfaces()
|
|||||||
status_t
|
status_t
|
||||||
list_interfaces(int family, void* _buffer, size_t* bufferSize)
|
list_interfaces(int family, void* _buffer, size_t* bufferSize)
|
||||||
{
|
{
|
||||||
MutexLocker locker(sLock);
|
RecursiveLocker locker(sLock);
|
||||||
|
|
||||||
UserBuffer buffer(_buffer, *bufferSize);
|
UserBuffer buffer(_buffer, *bufferSize);
|
||||||
|
|
||||||
@ -1619,7 +1620,7 @@ list_interfaces(int family, void* _buffer, size_t* bufferSize)
|
|||||||
status_t
|
status_t
|
||||||
init_interfaces()
|
init_interfaces()
|
||||||
{
|
{
|
||||||
mutex_init(&sLock, "net interfaces");
|
recursive_lock_init(&sLock, "net interfaces");
|
||||||
mutex_init(&sHashLock, "net local addresses");
|
mutex_init(&sHashLock, "net local addresses");
|
||||||
|
|
||||||
new (&sInterfaces) InterfaceList;
|
new (&sInterfaces) InterfaceList;
|
||||||
@ -1650,7 +1651,7 @@ uninit_interfaces()
|
|||||||
remove_debugger_command("net_route", &dump_route);
|
remove_debugger_command("net_route", &dump_route);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
mutex_destroy(&sLock);
|
recursive_lock_destroy(&sLock);
|
||||||
mutex_destroy(&sHashLock);
|
mutex_destroy(&sHashLock);
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user