mirror of
https://github.com/apache/nuttx.git
synced 2026-06-03 22:20:31 +08:00
Revert "tun: Fix the error of calling tun_close when tun_txavail or tun_txavail_work is executed"
This reverts commit 0f1a49bba5.
Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
This commit is contained in:
+5
-33
@@ -184,7 +184,7 @@ static int tun_rmmac(FAR struct net_driver_s *dev, FAR const uint8_t *mac);
|
|||||||
static int tun_dev_init(FAR struct tun_device_s *priv,
|
static int tun_dev_init(FAR struct tun_device_s *priv,
|
||||||
FAR struct file *filep,
|
FAR struct file *filep,
|
||||||
FAR const char *devfmt, bool tun);
|
FAR const char *devfmt, bool tun);
|
||||||
static int tun_dev_uninit(FAR struct tun_device_s *priv);
|
static void tun_dev_uninit(FAR struct tun_device_s *priv);
|
||||||
|
|
||||||
/* File interface */
|
/* File interface */
|
||||||
|
|
||||||
@@ -775,22 +775,14 @@ 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;
|
||||||
int ret = nxmutex_lock(&priv->lock);
|
|
||||||
|
|
||||||
if (ret < 0)
|
|
||||||
{
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Schedule to perform the TX poll on the worker thread. */
|
/* Schedule to perform the TX poll on the worker thread. */
|
||||||
|
|
||||||
if (priv->bifup && work_available(&priv->work))
|
if (work_available(&priv->work))
|
||||||
{
|
{
|
||||||
work_queue(TUNWORK, &priv->work, tun_txavail_work, priv, 0);
|
work_queue(TUNWORK, &priv->work, tun_txavail_work, priv, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
nxmutex_unlock(&priv->lock);
|
|
||||||
|
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -913,27 +905,12 @@ static int tun_dev_init(FAR struct tun_device_s *priv,
|
|||||||
* Name: tun_dev_uninit
|
* Name: tun_dev_uninit
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
static int tun_dev_uninit(FAR struct tun_device_s *priv)
|
static void tun_dev_uninit(FAR struct tun_device_s *priv)
|
||||||
{
|
{
|
||||||
int ret;
|
|
||||||
|
|
||||||
ret = nxmutex_lock(&priv->lock);
|
|
||||||
if (ret < 0)
|
|
||||||
{
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Put the interface in the down state */
|
/* Put the interface in the down state */
|
||||||
|
|
||||||
tun_ifdown(&priv->dev);
|
tun_ifdown(&priv->dev);
|
||||||
|
|
||||||
if (!work_available(&priv->work))
|
|
||||||
{
|
|
||||||
work_cancel_sync(TUNWORK, &priv->work);
|
|
||||||
}
|
|
||||||
|
|
||||||
nxmutex_unlock(&priv->lock);
|
|
||||||
|
|
||||||
/* Remove the device from the OS */
|
/* Remove the device from the OS */
|
||||||
|
|
||||||
netdev_unregister(&priv->dev);
|
netdev_unregister(&priv->dev);
|
||||||
@@ -941,8 +918,6 @@ static int tun_dev_uninit(FAR struct tun_device_s *priv)
|
|||||||
nxmutex_destroy(&priv->lock);
|
nxmutex_destroy(&priv->lock);
|
||||||
nxsem_destroy(&priv->read_wait_sem);
|
nxsem_destroy(&priv->read_wait_sem);
|
||||||
nxsem_destroy(&priv->write_wait_sem);
|
nxsem_destroy(&priv->write_wait_sem);
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
@@ -966,11 +941,8 @@ static int tun_close(FAR struct file *filep)
|
|||||||
ret = nxmutex_lock(&tun->lock);
|
ret = nxmutex_lock(&tun->lock);
|
||||||
if (ret >= 0)
|
if (ret >= 0)
|
||||||
{
|
{
|
||||||
ret = tun_dev_uninit(priv);
|
tun->free_tuns |= (1 << intf);
|
||||||
if (ret >= 0)
|
tun_dev_uninit(priv);
|
||||||
{
|
|
||||||
tun->free_tuns |= (1 << intf);
|
|
||||||
}
|
|
||||||
|
|
||||||
nxmutex_unlock(&tun->lock);
|
nxmutex_unlock(&tun->lock);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user