mirror of
https://github.com/apache/nuttx.git
synced 2026-09-22 06:04:28 +08:00
fs: move out nx_close from filelock
If the close is blocked(like net close timeout 5s), then other file operation can't access in this 5s. Change-Id: Ia6c4ec88d90db0330134d0aaa30e94cb71c8a066 Signed-off-by: ligd <liguiding1@xiaomi.com>
This commit is contained in:
+8
-3
@@ -483,6 +483,8 @@ int dup2(int fd1, int fd2)
|
||||
int nx_close(int fd)
|
||||
{
|
||||
FAR struct filelist *list;
|
||||
FAR struct file *filep;
|
||||
FAR struct file file;
|
||||
int ret;
|
||||
|
||||
/* Get the thread-specific file list. It should never be NULL in this
|
||||
@@ -510,11 +512,14 @@ int nx_close(int fd)
|
||||
return -EBADF;
|
||||
}
|
||||
|
||||
ret = file_close(&list->fl_files[fd / CONFIG_NFILE_DESCRIPTORS_PER_BLOCK]
|
||||
[fd % CONFIG_NFILE_DESCRIPTORS_PER_BLOCK]);
|
||||
filep = &list->fl_files[fd / CONFIG_NFILE_DESCRIPTORS_PER_BLOCK]
|
||||
[fd % CONFIG_NFILE_DESCRIPTORS_PER_BLOCK];
|
||||
memcpy(&file, filep, sizeof(struct file));
|
||||
memset(filep, 0, sizeof(struct file));
|
||||
|
||||
_files_semgive(list);
|
||||
|
||||
return ret;
|
||||
return file_close(&file);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
|
||||
Reference in New Issue
Block a user