net/local: correct the sendto() return length
return length should be data length Signed-off-by: chao.an <anchao@xiaomi.com>
This commit is contained in:
parent
14db894caf
commit
f8e800765c
@ -156,8 +156,7 @@ static ssize_t local_sendto(FAR struct socket *psock,
|
||||
#ifdef CONFIG_NET_LOCAL_DGRAM
|
||||
FAR struct local_conn_s *conn = (FAR struct local_conn_s *)psock->s_conn;
|
||||
FAR struct sockaddr_un *unaddr = (FAR struct sockaddr_un *)to;
|
||||
ssize_t nsent;
|
||||
int ret;
|
||||
ssize_t ret;
|
||||
|
||||
/* Verify that a valid address has been provided */
|
||||
|
||||
@ -212,7 +211,7 @@ static ssize_t local_sendto(FAR struct socket *psock,
|
||||
ret = local_create_halfduplex(conn, unaddr->sun_path);
|
||||
if (ret < 0)
|
||||
{
|
||||
nerr("ERROR: Failed to create FIFO for %s: %d\n",
|
||||
nerr("ERROR: Failed to create FIFO for %s: %zd\n",
|
||||
conn->lc_path, ret);
|
||||
return ret;
|
||||
}
|
||||
@ -224,25 +223,18 @@ static ssize_t local_sendto(FAR struct socket *psock,
|
||||
(flags & MSG_DONTWAIT) != 0);
|
||||
if (ret < 0)
|
||||
{
|
||||
nerr("ERROR: Failed to open FIFO for %s: %d\n",
|
||||
nerr("ERROR: Failed to open FIFO for %s: %zd\n",
|
||||
unaddr->sun_path, ret);
|
||||
|
||||
nsent = ret;
|
||||
goto errout_with_halfduplex;
|
||||
}
|
||||
|
||||
/* Send the packet */
|
||||
|
||||
nsent = local_send_packet(&conn->lc_outfile, buf, len);
|
||||
if (nsent < 0)
|
||||
ret = local_send_packet(&conn->lc_outfile, buf, len);
|
||||
if (ret < 0)
|
||||
{
|
||||
nerr("ERROR: Failed to send the packet: %d\n", ret);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* local_send_packet returns 0 if all 'len' bytes were sent */
|
||||
|
||||
nsent = len;
|
||||
nerr("ERROR: Failed to send the packet: %zd\n", ret);
|
||||
}
|
||||
|
||||
/* Now we can close the write-only socket descriptor */
|
||||
@ -255,7 +247,8 @@ errout_with_halfduplex:
|
||||
/* Release our reference to the half duplex FIFO */
|
||||
|
||||
local_release_halfduplex(conn);
|
||||
return nsent;
|
||||
|
||||
return ret;
|
||||
#else
|
||||
return -EISCONN;
|
||||
#endif /* CONFIG_NET_LOCAL_DGRAM */
|
||||
|
Loading…
Reference in New Issue
Block a user