net/icmp: Save poll device in icmp_poll_s
ICMP's conn->dev is changing in icmp_sendmsg, when sending to different address, or when error occurs (like NETDEV_DOWN). Then the poll callback cannot be dropped from previous dev in free, because the dev is wrong. So add dev to struct icmp_poll_s just like struct udp_poll_s. Signed-off-by: Zhe Weng <wengzhe@xiaomi.com>
This commit is contained in:
parent
c1bcf59a85
commit
f71fb738c5
2 changed files with 3 additions and 1 deletions
|
|
@ -69,6 +69,7 @@ struct devif_callback_s; /* Forward reference */
|
|||
struct icmp_poll_s
|
||||
{
|
||||
FAR struct socket *psock; /* IPPROTO_ICMP socket structure */
|
||||
FAR struct net_driver_s *dev; /* Needed to free the callback structure */
|
||||
FAR struct pollfd *fds; /* Needed to handle poll events */
|
||||
FAR struct devif_callback_s *cb; /* Needed to teardown the poll */
|
||||
};
|
||||
|
|
|
|||
|
|
@ -181,6 +181,7 @@ int icmp_pollsetup(FAR struct socket *psock, FAR struct pollfd *fds)
|
|||
/* Initialize the poll info container */
|
||||
|
||||
info->psock = psock;
|
||||
info->dev = conn->dev;
|
||||
info->fds = fds;
|
||||
info->cb = cb;
|
||||
|
||||
|
|
@ -272,7 +273,7 @@ int icmp_pollteardown(FAR struct socket *psock, FAR struct pollfd *fds)
|
|||
{
|
||||
/* Release the callback */
|
||||
|
||||
icmp_callback_free(conn->dev, conn, info->cb);
|
||||
icmp_callback_free(info->dev, conn, info->cb);
|
||||
|
||||
/* Release the poll/select data slot */
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue