mirror of
https://github.com/apache/nuttx.git
synced 2026-05-26 10:46:28 +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
@@ -30,6 +30,7 @@
|
||||
#include <errno.h>
|
||||
|
||||
#include <nuttx/cancelpt.h>
|
||||
#include <nuttx/fs/fs.h>
|
||||
#include <nuttx/net/net.h>
|
||||
|
||||
#include "socket/socket.h"
|
||||
@@ -141,6 +142,7 @@ ssize_t psock_sendmsg(FAR struct socket *psock, FAR struct msghdr *msg,
|
||||
ssize_t sendmsg(int sockfd, FAR struct msghdr *msg, int flags)
|
||||
{
|
||||
FAR struct socket *psock;
|
||||
FAR struct file *filep;
|
||||
ssize_t ret;
|
||||
|
||||
/* sendmsg() is a cancellation point */
|
||||
@@ -149,13 +151,14 @@ ssize_t sendmsg(int sockfd, FAR struct msghdr *msg, int flags)
|
||||
|
||||
/* Get the underlying socket structure */
|
||||
|
||||
ret = sockfd_socket(sockfd, &psock);
|
||||
ret = sockfd_socket(sockfd, &filep, &psock);
|
||||
|
||||
/* Let psock_sendmsg() do all of the work */
|
||||
|
||||
if (ret == OK)
|
||||
{
|
||||
ret = psock_sendmsg(psock, msg, flags);
|
||||
fs_putfilep(filep);
|
||||
}
|
||||
|
||||
if (ret < 0)
|
||||
|
||||
Reference in New Issue
Block a user