Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

local_socket: corrent send/recv return value after shutdown #14103

Merged
merged 1 commit into from
Oct 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions net/local/local_recvmsg.c
Original file line number Diff line number Diff line change
Expand Up @@ -539,11 +539,19 @@ psock_dgram_recvfrom(FAR struct socket *psock, FAR void *buf, size_t len,
ssize_t local_recvmsg(FAR struct socket *psock, FAR struct msghdr *msg,
int flags)
{
FAR struct local_conn_s *conn = psock->s_conn;
FAR socklen_t *fromlen = &msg->msg_namelen;
FAR struct sockaddr *from = msg->msg_name;
FAR void *buf = msg->msg_iov->iov_base;
size_t len = msg->msg_iov->iov_len;

/* Check shutdown state */

if (conn->lc_infile.f_inode == NULL)
{
return 0;
}

DEBUGASSERT(buf);

/* Check for a stream socket */
Expand Down
16 changes: 13 additions & 3 deletions net/local/local_sendmsg.c
Original file line number Diff line number Diff line change
Expand Up @@ -431,12 +431,20 @@ static ssize_t local_sendto(FAR struct socket *psock,
ssize_t local_sendmsg(FAR struct socket *psock, FAR struct msghdr *msg,
int flags)
{
FAR struct local_conn_s *conn = psock->s_conn;
FAR const struct sockaddr *to = msg->msg_name;
FAR const struct iovec *buf = msg->msg_iov;
socklen_t tolen = msg->msg_namelen;
size_t len = msg->msg_iovlen;

/* Check shutdown state */

if (conn->lc_outfile.f_inode == NULL)
{
return -EPIPE;
}

#ifdef CONFIG_NET_LOCAL_SCM
FAR struct local_conn_s *conn = psock->s_conn;
int count = 0;

if (msg->msg_control &&
Expand All @@ -448,17 +456,19 @@ ssize_t local_sendmsg(FAR struct socket *psock, FAR struct msghdr *msg,
return count;
}
}
#endif /* CONFIG_NET_LOCAL_SCM */

len = to ? local_sendto(psock, buf, len, flags, to, tolen) :
local_send(psock, buf, len, flags);
#ifdef CONFIG_NET_LOCAL_SCM

if (len < 0 && count > 0)
{
net_lock();
local_freectl(conn, count);
net_unlock();
}
#else
len = to ? local_sendto(psock, buf, len, flags, to, tolen) :
local_send(psock, buf, len, flags);
#endif

return len;
Expand Down
Loading