usrsock_server: fix issues with usrsock_rpmsg_sendto_handler

If the current poll setup only has POLLIN, adding POLLOUT does not cause the
protocol stack to refocus on flags such as TCP_ACK or UDP_POLL, the user is
not notified when flags for POLLOUT relationships appear and vice versa,
so we have to call poll_setup again.

Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
This commit is contained in:
zhanghongyu 2023-05-11 21:25:02 +08:00 committed by Xiang Xiao
parent aee45c9c43
commit 06a10202af

View File

@ -496,7 +496,8 @@ out:
retr = usrsock_rpmsg_send_ack(ept, events, req->head.xid, ret);
if (retr >= 0 && events == 0)
{
usrsock_rpmsg_poll_setup(&priv->pfds[req->usockid], POLLOUT);
usrsock_rpmsg_poll_setup(&priv->pfds[req->usockid],
priv->pfds[req->usockid].events | POLLOUT);
}
if (priv->iov[0].iov_base)
@ -640,7 +641,8 @@ static int usrsock_rpmsg_recvfrom_handler(FAR struct rpmsg_endpoint *ept,
if (retr >= 0 && events == 0)
{
usrsock_rpmsg_poll_setup(&priv->pfds[req->usockid], POLLIN);
usrsock_rpmsg_poll_setup(&priv->pfds[req->usockid],
priv->pfds[req->usockid].events | POLLIN);
}
return retr;
@ -1054,16 +1056,21 @@ static void usrsock_rpmsg_poll_setup(FAR struct pollfd *pfds,
if (events)
{
if (!pfds->events)
if (pfds->events)
{
ret = psock_poll(psock, pfds, false);
}
if (ret >= 0)
{
/* The protocol stack monitor flag is different when the events is
* POLLIN or POLLOUT, so we have to call poll_setup again.
*/
pfds->revents = 0;
pfds->events = events;
ret = psock_poll(psock, pfds, true);
}
else
{
pfds->events = events;
}
}
else
{
@ -1127,13 +1134,9 @@ static void usrsock_rpmsg_poll_cb(FAR struct pollfd *pfds)
}
}
if (!(pfds->events & (POLLIN | POLLOUT)))
{
usrsock_rpmsg_poll_setup(pfds, 0);
}
if (events != 0)
{
usrsock_rpmsg_poll_setup(pfds, pfds->events);
usrsock_rpmsg_send_event(priv->epts[pfds->fd], pfds->fd, events);
}