mirror of
https://github.com/apache/nuttx.git
synced 2025-01-13 08:38:38 +08:00
local_socket: corrent send/recv return value after shutdown
Signed-off-by: ligd <liguiding1@xiaomi.com>
This commit is contained in:
parent
a5c0dbe772
commit
01676cb9cd
2 changed files with 21 additions and 3 deletions
|
@ -539,11 +539,19 @@ errout_with_halfduplex:
|
||||||
ssize_t local_recvmsg(FAR struct socket *psock, FAR struct msghdr *msg,
|
ssize_t local_recvmsg(FAR struct socket *psock, FAR struct msghdr *msg,
|
||||||
int flags)
|
int flags)
|
||||||
{
|
{
|
||||||
|
FAR struct local_conn_s *conn = psock->s_conn;
|
||||||
FAR socklen_t *fromlen = &msg->msg_namelen;
|
FAR socklen_t *fromlen = &msg->msg_namelen;
|
||||||
FAR struct sockaddr *from = msg->msg_name;
|
FAR struct sockaddr *from = msg->msg_name;
|
||||||
FAR void *buf = msg->msg_iov->iov_base;
|
FAR void *buf = msg->msg_iov->iov_base;
|
||||||
size_t len = msg->msg_iov->iov_len;
|
size_t len = msg->msg_iov->iov_len;
|
||||||
|
|
||||||
|
/* Check shutdown state */
|
||||||
|
|
||||||
|
if (conn->lc_infile.f_inode == NULL)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
DEBUGASSERT(buf);
|
DEBUGASSERT(buf);
|
||||||
|
|
||||||
/* Check for a stream socket */
|
/* Check for a stream socket */
|
||||||
|
|
|
@ -431,12 +431,20 @@ errout_with_lock:
|
||||||
ssize_t local_sendmsg(FAR struct socket *psock, FAR struct msghdr *msg,
|
ssize_t local_sendmsg(FAR struct socket *psock, FAR struct msghdr *msg,
|
||||||
int flags)
|
int flags)
|
||||||
{
|
{
|
||||||
|
FAR struct local_conn_s *conn = psock->s_conn;
|
||||||
FAR const struct sockaddr *to = msg->msg_name;
|
FAR const struct sockaddr *to = msg->msg_name;
|
||||||
FAR const struct iovec *buf = msg->msg_iov;
|
FAR const struct iovec *buf = msg->msg_iov;
|
||||||
socklen_t tolen = msg->msg_namelen;
|
socklen_t tolen = msg->msg_namelen;
|
||||||
size_t len = msg->msg_iovlen;
|
size_t len = msg->msg_iovlen;
|
||||||
|
|
||||||
|
/* Check shutdown state */
|
||||||
|
|
||||||
|
if (conn->lc_outfile.f_inode == NULL)
|
||||||
|
{
|
||||||
|
return -EPIPE;
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef CONFIG_NET_LOCAL_SCM
|
#ifdef CONFIG_NET_LOCAL_SCM
|
||||||
FAR struct local_conn_s *conn = psock->s_conn;
|
|
||||||
int count = 0;
|
int count = 0;
|
||||||
|
|
||||||
if (msg->msg_control &&
|
if (msg->msg_control &&
|
||||||
|
@ -448,17 +456,19 @@ ssize_t local_sendmsg(FAR struct socket *psock, FAR struct msghdr *msg,
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif /* CONFIG_NET_LOCAL_SCM */
|
|
||||||
|
|
||||||
len = to ? local_sendto(psock, buf, len, flags, to, tolen) :
|
len = to ? local_sendto(psock, buf, len, flags, to, tolen) :
|
||||||
local_send(psock, buf, len, flags);
|
local_send(psock, buf, len, flags);
|
||||||
#ifdef CONFIG_NET_LOCAL_SCM
|
|
||||||
if (len < 0 && count > 0)
|
if (len < 0 && count > 0)
|
||||||
{
|
{
|
||||||
net_lock();
|
net_lock();
|
||||||
local_freectl(conn, count);
|
local_freectl(conn, count);
|
||||||
net_unlock();
|
net_unlock();
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
len = to ? local_sendto(psock, buf, len, flags, to, tolen) :
|
||||||
|
local_send(psock, buf, len, flags);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return len;
|
return len;
|
||||||
|
|
Loading…
Reference in a new issue