Skip to content

Commit c528244

Browse files
crafcat7xiaoxiang781216
authored andcommitted
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 <[email protected]>
1 parent 0bf2634 commit c528244

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

fs/vfs/fs_lock.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -767,15 +767,16 @@ void file_closelk(FAR struct file *filep)
767767
goto out;
768768
}
769769

770+
nxmutex_lock(&g_protect_lock);
770771
bucket = file_lock_find_bucket(path);
771772
if (bucket == NULL)
772773
{
773774
/* There is no bucket here, so we don't need to free it. */
774775

776+
nxmutex_unlock(&g_protect_lock);
775777
goto out;
776778
}
777779

778-
nxmutex_lock(&g_protect_lock);
779780
list_for_every_entry_safe(&bucket->list, file_lock, temp,
780781
struct file_lock_s, fl_node)
781782
{

0 commit comments

Comments
 (0)