usrsock_server: Raise error earlier for large sendto request
It's better to raise error before client sends its (NIOVEC+1)th buffer (and release buffers held by server), otherwise the client may stuck at getting (NIOVEC+1)th tx buffer if NIOVEC is equal to rpmsg buffer num. Signed-off-by: Zhe Weng <wengzhe@xiaomi.com>
This commit is contained in:
parent
0d118ec214
commit
7671ed9615
@ -416,16 +416,19 @@ static int usrsock_rpmsg_sendto_handler(FAR struct rpmsg_endpoint *ept,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (i == CONFIG_NET_USRSOCK_RPMSG_SERVER_NIOVEC)
|
|
||||||
{
|
|
||||||
ret = -ENOMEM;
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Partial packet ? continue to fetch */
|
/* Partial packet ? continue to fetch */
|
||||||
|
|
||||||
if (priv->remain > 0)
|
if (priv->remain > 0)
|
||||||
{
|
{
|
||||||
|
/* We've used the last I/O vector, cannot continue. */
|
||||||
|
|
||||||
|
if (i == CONFIG_NET_USRSOCK_RPMSG_SERVER_NIOVEC - 1)
|
||||||
|
{
|
||||||
|
nerr("ERROR: Request %d too large!\n", req->usockid);
|
||||||
|
ret = -ENOMEM;
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
else if (priv->remain < 0)
|
else if (priv->remain < 0)
|
||||||
@ -461,11 +464,15 @@ static int usrsock_rpmsg_sendto_handler(FAR struct rpmsg_endpoint *ept,
|
|||||||
priv->remain = sizeof(*req) + req->addrlen + req->buflen - len;
|
priv->remain = sizeof(*req) + req->addrlen + req->buflen - len;
|
||||||
if (priv->remain > 0)
|
if (priv->remain > 0)
|
||||||
{
|
{
|
||||||
|
#if CONFIG_NET_USRSOCK_RPMSG_SERVER_NIOVEC >= 2
|
||||||
priv->iov[0].iov_base = data;
|
priv->iov[0].iov_base = data;
|
||||||
priv->iov[0].iov_len = len;
|
priv->iov[0].iov_len = len;
|
||||||
|
|
||||||
rpmsg_hold_rx_buffer(ept, data);
|
rpmsg_hold_rx_buffer(ept, data);
|
||||||
return 0;
|
return 0;
|
||||||
|
#else
|
||||||
|
ret = -ENOMEM;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user