tun: Fix the error of calling tun_close when tun_txavail or tun_txavail_work is executed
When tun_txavail_work is running, switch to tun_close thread and priv->lock will be destroyed, then switch back to tun_txavail_work thread, an error will occur when nxmutex_unlock(&priv->lock) Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
This commit is contained in:
parent
3b469271d7
commit
5374af077b
@ -775,14 +775,21 @@ static void tun_txavail_work(FAR void *arg)
|
|||||||
static int tun_txavail(FAR struct net_driver_s *dev)
|
static int tun_txavail(FAR struct net_driver_s *dev)
|
||||||
{
|
{
|
||||||
FAR struct tun_device_s *priv = (FAR struct tun_device_s *)dev->d_private;
|
FAR struct tun_device_s *priv = (FAR struct tun_device_s *)dev->d_private;
|
||||||
|
irqstate_t flags;
|
||||||
|
|
||||||
/* Schedule to perform the TX poll on the worker thread. */
|
flags = enter_critical_section(); /* No interrupts */
|
||||||
|
|
||||||
if (work_available(&priv->work))
|
/* Schedule to perform the TX poll on the worker thread when priv->bifup
|
||||||
|
* is true.
|
||||||
|
*/
|
||||||
|
|
||||||
|
if (priv->bifup && work_available(&priv->work))
|
||||||
{
|
{
|
||||||
work_queue(TUNWORK, &priv->work, tun_txavail_work, priv, 0);
|
work_queue(TUNWORK, &priv->work, tun_txavail_work, priv, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
leave_critical_section(flags);
|
||||||
|
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -911,6 +918,8 @@ static void tun_dev_uninit(FAR struct tun_device_s *priv)
|
|||||||
|
|
||||||
tun_ifdown(&priv->dev);
|
tun_ifdown(&priv->dev);
|
||||||
|
|
||||||
|
work_cancel_sync(TUNWORK, &priv->work);
|
||||||
|
|
||||||
/* Remove the device from the OS */
|
/* Remove the device from the OS */
|
||||||
|
|
||||||
netdev_unregister(&priv->dev);
|
netdev_unregister(&priv->dev);
|
||||||
|
Loading…
Reference in New Issue
Block a user