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
|
@ -539,11 +539,19 @@ errout_with_halfduplex:
|
|||
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 */
|
||||
|
|
|
@ -431,12 +431,20 @@ errout_with_lock:
|
|||
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 &&
|
||||
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue