mirror of
https://github.com/apache/nuttx.git
synced 2026-05-31 23:40:19 +08:00
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:
committed by
Xiang Xiao
parent
f2fd0bc148
commit
43223124ec
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user