mirror of
https://github.com/apache/nuttx.git
synced 2026-09-27 18:58:27 +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
+4
-1
@@ -32,6 +32,7 @@
|
||||
#include <errno.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <nuttx/fs/fs.h>
|
||||
#include <nuttx/net/net.h>
|
||||
|
||||
#include "socket/socket.h"
|
||||
@@ -151,17 +152,19 @@ int psock_bind(FAR struct socket *psock, const struct sockaddr *addr,
|
||||
int bind(int sockfd, const struct sockaddr *addr, socklen_t addrlen)
|
||||
{
|
||||
FAR struct socket *psock;
|
||||
FAR struct file *filep;
|
||||
int ret;
|
||||
|
||||
/* Get the underlying socket structure */
|
||||
|
||||
ret = sockfd_socket(sockfd, &psock);
|
||||
ret = sockfd_socket(sockfd, &filep, &psock);
|
||||
|
||||
/* Then let psock_bind do all of the work */
|
||||
|
||||
if (ret == OK)
|
||||
{
|
||||
ret = psock_bind(psock, addr, addrlen);
|
||||
fs_putfilep(filep);
|
||||
}
|
||||
|
||||
if (ret < 0)
|
||||
|
||||
Reference in New Issue
Block a user