mirror of
https://github.com/apache/nuttx.git
synced 2026-05-26 10:46:28 +08:00
net/soerr: add new _SO_CONN_SETERRNO() macro
support so error code set from conn instance Signed-off-by: chao an <anchao@xiaomi.com>
This commit is contained in:
@@ -133,8 +133,7 @@ ssize_t psock_sendfile(FAR struct socket *psock, FAR struct file *infile,
|
||||
|
||||
if (ret < 0)
|
||||
{
|
||||
FAR struct socket_conn_s *conn = psock->s_conn;
|
||||
conn->s_error = -ret;
|
||||
_SO_SETERRNO(psock, -ret);
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
||||
+19
-3
@@ -94,18 +94,34 @@
|
||||
/* Macro to set socket errors */
|
||||
|
||||
#ifdef CONFIG_NET_SOCKOPTS
|
||||
# define _SO_SETERRNO(s,e) \
|
||||
# define _SO_CONN_SETERRNO(c,e) \
|
||||
do \
|
||||
{ \
|
||||
if (s != NULL && (s)->s_conn != NULL) \
|
||||
if ((c) != NULL) \
|
||||
{ \
|
||||
FAR struct socket_conn_s *_conn = (s)->s_conn; \
|
||||
FAR struct socket_conn_s *_conn = \
|
||||
(FAR struct socket_conn_s *)(c); \
|
||||
_conn->s_error = (int16_t)e; \
|
||||
} \
|
||||
set_errno(e); \
|
||||
} \
|
||||
while (0)
|
||||
|
||||
# define _SO_SETERRNO(s,e) \
|
||||
do \
|
||||
{ \
|
||||
if (s != NULL) \
|
||||
{ \
|
||||
_SO_CONN_SETERRNO((s)->s_conn, e); \
|
||||
} \
|
||||
else \
|
||||
{ \
|
||||
set_errno(e); \
|
||||
} \
|
||||
} \
|
||||
while (0)
|
||||
#else
|
||||
# define _SO_CONN_SETERRNO(c,e) set_errno(e)
|
||||
# define _SO_SETERRNO(s,e) set_errno(e)
|
||||
#endif /* CONFIG_NET_SOCKOPTS */
|
||||
|
||||
|
||||
@@ -165,10 +165,7 @@ static uint16_t tcp_monitor_event(FAR struct net_driver_s *dev,
|
||||
|
||||
/* Clear the socket error */
|
||||
|
||||
#ifdef CONFIG_NET_SOCKOPTS
|
||||
conn->sconn.s_error = OK;
|
||||
#endif
|
||||
set_errno(OK);
|
||||
_SO_CONN_SETERRNO(conn, OK);
|
||||
|
||||
/* Indicate that the socket is now connected */
|
||||
|
||||
|
||||
@@ -128,10 +128,7 @@ static uint16_t tcp_poll_eventhandler(FAR struct net_driver_s *dev,
|
||||
reason = ECONNREFUSED;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_NET_SOCKOPTS
|
||||
info->conn->sconn.s_error = reason;
|
||||
#endif
|
||||
set_errno(reason);
|
||||
_SO_CONN_SETERRNO(info->conn, reason);
|
||||
|
||||
/* Mark that the connection has been lost */
|
||||
|
||||
|
||||
Reference in New Issue
Block a user