mirror of
https://github.com/apache/nuttx.git
synced 2026-06-02 01:21:26 +08:00
net: Implement shutdown() for local stream socket
Signed-off-by: Zhe Weng <wengzhe@xiaomi.com>
This commit is contained in:
@@ -228,7 +228,8 @@ psock_stream_recvfrom(FAR struct socket *psock, FAR void *buf, size_t len,
|
|||||||
|
|
||||||
/* Verify that this is a connected peer socket */
|
/* Verify that this is a connected peer socket */
|
||||||
|
|
||||||
if (conn->lc_state != LOCAL_STATE_CONNECTED)
|
if (conn->lc_state != LOCAL_STATE_CONNECTED ||
|
||||||
|
conn->lc_infile.f_inode == NULL)
|
||||||
{
|
{
|
||||||
if (conn->lc_state == LOCAL_STATE_CONNECTING)
|
if (conn->lc_state == LOCAL_STATE_CONNECTING)
|
||||||
{
|
{
|
||||||
@@ -239,10 +240,6 @@ psock_stream_recvfrom(FAR struct socket *psock, FAR void *buf, size_t len,
|
|||||||
return -ENOTCONN;
|
return -ENOTCONN;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* The incoming FIFO should be open */
|
|
||||||
|
|
||||||
DEBUGASSERT(conn->lc_infile.f_inode != NULL);
|
|
||||||
|
|
||||||
/* Read the packet */
|
/* Read the packet */
|
||||||
|
|
||||||
ret = psock_fifo_read(psock, buf, &readlen, true);
|
ret = psock_fifo_read(psock, buf, &readlen, true);
|
||||||
|
|||||||
@@ -983,10 +983,43 @@ errout:
|
|||||||
|
|
||||||
static int local_shutdown(FAR struct socket *psock, int how)
|
static int local_shutdown(FAR struct socket *psock, int how)
|
||||||
{
|
{
|
||||||
/* TODO: implement this. */
|
DEBUGASSERT(psock != NULL && psock->s_conn != NULL &&
|
||||||
|
psock->s_domain == PF_LOCAL);
|
||||||
|
|
||||||
nerr("ERROR: local_shutdown is not implemented");
|
switch (psock->s_type)
|
||||||
return -ENOTSUP;
|
{
|
||||||
|
#ifdef CONFIG_NET_LOCAL_STREAM
|
||||||
|
case SOCK_STREAM:
|
||||||
|
{
|
||||||
|
FAR struct local_conn_s *conn = psock->s_conn;
|
||||||
|
if (how & SHUT_RD)
|
||||||
|
{
|
||||||
|
if (conn->lc_infile.f_inode != NULL)
|
||||||
|
{
|
||||||
|
file_close(&conn->lc_infile);
|
||||||
|
conn->lc_infile.f_inode = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (how & SHUT_WR)
|
||||||
|
{
|
||||||
|
if (conn->lc_outfile.f_inode != NULL)
|
||||||
|
{
|
||||||
|
file_close(&conn->lc_outfile);
|
||||||
|
conn->lc_outfile.f_inode = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return OK;
|
||||||
|
#endif
|
||||||
|
#ifdef CONFIG_NET_LOCAL_DGRAM
|
||||||
|
case SOCK_DGRAM:
|
||||||
|
return -EOPNOTSUPP;
|
||||||
|
#endif
|
||||||
|
default:
|
||||||
|
return -EBADF;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
|
|||||||
Reference in New Issue
Block a user