You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by xi...@apache.org on 2021/07/03 12:26:00 UTC
[incubator-nuttx] branch master updated: fs: move out nx_close from
filelock
This is an automated email from the ASF dual-hosted git repository.
xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git
The following commit(s) were added to refs/heads/master by this push:
new 6d3ccf3 fs: move out nx_close from filelock
6d3ccf3 is described below
commit 6d3ccf37abc90a8263bf3181d85c80b086825495
Author: ligd <li...@xiaomi.com>
AuthorDate: Thu Jun 24 22:06:29 2021 +0800
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 <li...@xiaomi.com>
---
fs/inode/fs_files.c | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/fs/inode/fs_files.c b/fs/inode/fs_files.c
index 738c3ce..50ec037 100644
--- a/fs/inode/fs_files.c
+++ b/fs/inode/fs_files.c
@@ -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);
}
/****************************************************************************