net: nsos_sockets: notify pollers on socket close
Raise the poll signal when the socket is being closed to prevent users of `zsock_poll` blocking after the socket is no more. Signed-off-by: Jordan Yates <jordan@embeint.com>
This commit is contained in:
parent
8934b810cc
commit
023e266651
1 changed files with 8 additions and 0 deletions
|
@ -258,6 +258,7 @@ static ssize_t nsos_write(void *obj, const void *buf, size_t sz)
|
||||||
static int nsos_close(void *obj)
|
static int nsos_close(void *obj)
|
||||||
{
|
{
|
||||||
struct nsos_socket *sock = obj;
|
struct nsos_socket *sock = obj;
|
||||||
|
struct nsos_socket_poll *poll;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
ret = nsi_host_close(sock->poll.mid.fd);
|
ret = nsi_host_close(sock->poll.mid.fd);
|
||||||
|
@ -265,6 +266,13 @@ static int nsos_close(void *obj)
|
||||||
errno = nsos_adapt_get_zephyr_errno();
|
errno = nsos_adapt_get_zephyr_errno();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SYS_DLIST_FOR_EACH_CONTAINER(&nsos_polls, poll, node) {
|
||||||
|
if (poll == &sock->poll) {
|
||||||
|
poll->mid.revents = ZSOCK_POLLHUP;
|
||||||
|
poll->mid.cb(&poll->mid);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
k_free(sock);
|
k_free(sock);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue