vfs/file: add reference counting to prevent accidental close during reading writing...

Signed-off-by: Shoukui Zhang <zhangshoukui@xiaomi.com>
This commit is contained in:
Shoukui Zhang
2023-12-25 15:04:01 +08:00
committed by Xiang Xiao
parent f2fd0bc148
commit 43223124ec
50 changed files with 335 additions and 146 deletions
+3 -1
View File
@@ -901,6 +901,7 @@ static int telnet_session(FAR struct telnet_session_s *session)
{
FAR struct telnet_dev_s *priv;
FAR struct socket *psock;
FAR struct file *filep;
int ret;
/* Allocate instance data for this driver */
@@ -931,7 +932,7 @@ static int telnet_session(FAR struct telnet_session_s *session)
* instance resided in the daemon's task group`).
*/
ret = sockfd_socket(session->ts_sd, &psock);
ret = sockfd_socket(session->ts_sd, &filep, &psock);
if (ret != OK)
{
nerr("ERROR: Failed to convert sd=%d to a socket structure\n",
@@ -940,6 +941,7 @@ static int telnet_session(FAR struct telnet_session_s *session)
}
ret = psock_dup2(psock, &priv->td_psock);
fs_putfilep(filep);
if (ret < 0)
{
nerr("ERROR: psock_dup2 failed: %d\n", ret);