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:
chenrun1 2024-05-24 16:12:16 +08:00 committed by Xiang Xiao
parent 0bf2634631
commit c528244f19

View File

@ -767,15 +767,16 @@ void file_closelk(FAR struct file *filep)
goto out;
}
nxmutex_lock(&g_protect_lock);
bucket = file_lock_find_bucket(path);
if (bucket == NULL)
{
/* There is no bucket here, so we don't need to free it. */
nxmutex_unlock(&g_protect_lock);
goto out;
}
nxmutex_lock(&g_protect_lock);
list_for_every_entry_safe(&bucket->list, file_lock, temp,
struct file_lock_s, fl_node)
{