mirror of
https://github.com/apache/nuttx.git
synced 2026-05-28 03:45:50 +08:00
fs_lock:Fixed the problem that in multi-threaded situations, the bucket may be deleted by other factors during the search process, resulting in assertion.
hsearch_r(item = (key = 0x61492174,data = ?),action = ?, retval = 0x6266AC44, htab = 0x6159B758) H 1tem = Ckey = 0x61492174, data= : · action = ? retval = 0x6266AC44 htab = 0x6159B758 haad - 0x61616300 ie= 0×38 file_lock_find_bucket(inline) filepath = 0x61492174 hretvalue = 0x6055991D item = (key = 0x61492174, data = 0x0) Signed-off-by: chenrun1 <chenrun1@xiaomi.com>
This commit is contained in:
+2
-1
@@ -767,15 +767,16 @@ void file_closelk(FAR struct file *filep)
|
|||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
nxmutex_lock(&g_protect_lock);
|
||||||
bucket = file_lock_find_bucket(path);
|
bucket = file_lock_find_bucket(path);
|
||||||
if (bucket == NULL)
|
if (bucket == NULL)
|
||||||
{
|
{
|
||||||
/* There is no bucket here, so we don't need to free it. */
|
/* There is no bucket here, so we don't need to free it. */
|
||||||
|
|
||||||
|
nxmutex_unlock(&g_protect_lock);
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
nxmutex_lock(&g_protect_lock);
|
|
||||||
list_for_every_entry_safe(&bucket->list, file_lock, temp,
|
list_for_every_entry_safe(&bucket->list, file_lock, temp,
|
||||||
struct file_lock_s, fl_node)
|
struct file_lock_s, fl_node)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user