mirror of
https://github.com/apache/nuttx.git
synced 2026-05-25 01:39:44 +08:00
Networking: The network device list was protected by a re-entrant semaphore. With the recent change to support network device callback, the network stack needs to access the network device list too. Some drivers, however, run the network stack from the interrupt level -- this is bad but a fact in the current state. Of course,those drivers are unable to take the semaphore and will assert.
The solution here is to eliminate the device devices semaphore altogether. This eliminates netdev_semtake() and netdev_semgive() and replaces them with net_lock() and net_unlock() which have larger scope as needed for this purpose.
This commit is contained in:
@@ -43,6 +43,7 @@
|
||||
|
||||
#include <nuttx/net/netdev.h>
|
||||
|
||||
#include "utils/utils.h"
|
||||
#include "netdev/netdev.h"
|
||||
|
||||
/****************************************************************************
|
||||
@@ -63,11 +64,12 @@
|
||||
bool netdev_verify(FAR struct net_driver_s *dev)
|
||||
{
|
||||
FAR struct net_driver_s *chkdev;
|
||||
net_lock_t save;
|
||||
bool valid = false;
|
||||
|
||||
/* Search the list of registered devices */
|
||||
|
||||
netdev_semtake();
|
||||
save = net_lock();
|
||||
for (chkdev = g_netdevices; chkdev != NULL; chkdev = chkdev->flink)
|
||||
{
|
||||
/* Is the the network device that we are looking for? */
|
||||
@@ -81,6 +83,6 @@ bool netdev_verify(FAR struct net_driver_s *dev)
|
||||
}
|
||||
}
|
||||
|
||||
netdev_semgive();
|
||||
net_unlock(save);
|
||||
return valid;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user