usrsock: Move event field to usrsock_message_common_s

Zero the events field for all response message

Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
This commit is contained in:
zhanghongyu 2022-03-22 22:35:01 +08:00 committed by Masayuki Ishikawa
parent c7b7162d5f
commit 16c1fec99d
3 changed files with 54 additions and 36 deletions

View File

@ -253,7 +253,7 @@ static int tsock_send_event(int fd, FAR struct daemon_priv_s *priv,
}
event.usockid = i + TEST_SOCKET_SOCKID_BASE;
event.events = events;
event.head.events = events;
wlen = write(fd, &event, sizeof(event));
if (wlen < 0)
@ -379,6 +379,7 @@ static int socket_request(int fd, FAR struct daemon_priv_s *priv,
resp.head.msgid = USRSOCK_MESSAGE_RESPONSE_ACK;
resp.head.flags = 0;
resp.head.events = 0;
resp.xid = req->head.xid;
resp.result = socketid;
@ -414,6 +415,7 @@ static int close_request(int fd, FAR struct daemon_priv_s *priv,
/* Prepare response. */
resp.head.msgid = USRSOCK_MESSAGE_RESPONSE_ACK;
resp.head.events = 0;
resp.xid = req->head.xid;
if (priv->conf->delay_all_responses)
{
@ -553,6 +555,7 @@ prepare:
resp.xid = req->head.xid;
resp.head.msgid = USRSOCK_MESSAGE_RESPONSE_ACK;
resp.head.flags = 0;
resp.head.events = 0;
if (priv->conf->endpoint_block_connect)
{
@ -746,6 +749,7 @@ prepare:
resp.xid = req->head.xid;
resp.head.msgid = USRSOCK_MESSAGE_RESPONSE_ACK;
resp.head.flags = 0;
resp.head.events = 0;
if (priv->conf->delay_all_responses)
{
@ -882,6 +886,7 @@ prepare:
resp.reqack.xid = req->head.xid;
resp.reqack.head.msgid = USRSOCK_MESSAGE_RESPONSE_DATA_ACK;
resp.reqack.head.flags = 0;
resp.reqack.head.events = 0;
if (priv->conf->delay_all_responses)
{
@ -1073,6 +1078,7 @@ prepare:
resp.xid = req->head.xid;
resp.head.msgid = USRSOCK_MESSAGE_RESPONSE_ACK;
resp.head.flags = 0;
resp.head.events = 0;
if (priv->conf->delay_all_responses)
{
@ -1179,6 +1185,7 @@ prepare:
resp.reqack.xid = req->head.xid;
resp.reqack.head.msgid = USRSOCK_MESSAGE_RESPONSE_DATA_ACK;
resp.reqack.head.flags = 0;
resp.reqack.head.events = 0;
if (priv->conf->delay_all_responses)
{
@ -1290,6 +1297,7 @@ prepare:
resp.reqack.xid = req->head.xid;
resp.reqack.head.msgid = USRSOCK_MESSAGE_RESPONSE_DATA_ACK;
resp.reqack.head.flags = 0;
resp.reqack.head.events = 0;
if (priv->conf->delay_all_responses)
{
@ -1549,6 +1557,7 @@ static int establish_blocked_connection(int fd,
priv->sockets_waiting_connect--;
resp->head.flags &= ~USRSOCK_MESSAGE_FLAG_REQ_IN_PROGRESS;
resp->head.events = 0;
wlen = write(fd, resp, sizeof(*resp));
if (wlen < 0)
@ -1600,6 +1609,7 @@ static int fail_blocked_connection(int fd, FAR struct daemon_priv_s *priv,
priv->sockets_waiting_connect--;
resp->head.flags &= ~USRSOCK_MESSAGE_FLAG_REQ_IN_PROGRESS;
resp->head.events = 0;
wlen = write(fd, resp, sizeof(*resp));
if (wlen < 0)

View File

@ -147,6 +147,7 @@ static int usrsock_rpmsg_send_ack(struct rpmsg_endpoint *ept,
ack.head.msgid = USRSOCK_MESSAGE_RESPONSE_ACK;
ack.head.flags = (result == -EINPROGRESS);
ack.head.events = 0;
ack.xid = xid;
ack.result = result;
@ -162,6 +163,7 @@ static int usrsock_rpmsg_send_data_ack(struct rpmsg_endpoint *ept,
{
ack->reqack.head.msgid = USRSOCK_MESSAGE_RESPONSE_DATA_ACK;
ack->reqack.head.flags = 0;
ack->reqack.head.events = 0;
ack->reqack.xid = xid;
ack->reqack.result = result;
@ -190,9 +192,9 @@ static int usrsock_rpmsg_send_event(struct rpmsg_endpoint *ept,
event.head.msgid = USRSOCK_MESSAGE_SOCKET_EVENT;
event.head.flags = USRSOCK_MESSAGE_FLAG_EVENT;
event.head.events = events;
event.usockid = usockid;
event.events = events;
return rpmsg_send(ept, &event, sizeof(event));
}

View File

@ -248,6 +248,7 @@ static int _send_ack_common(int fd,
{
resp->head.msgid = USRSOCK_MESSAGE_RESPONSE_ACK;
resp->head.flags = 0;
resp->head.events = 0;
resp->xid = xid;
/* Send ACK response. */
@ -447,7 +448,7 @@ static int usock_send_event(int fd, FAR struct gs2200m_s *priv,
}
event.usockid = i + SOCKET_BASE;
event.events = events;
event.head.events = events;
return _write_to_usock(fd, &event, sizeof(event));
}
@ -953,6 +954,7 @@ prepare:
resp.reqack.xid = req->head.xid;
resp.reqack.head.msgid = USRSOCK_MESSAGE_RESPONSE_DATA_ACK;
resp.reqack.head.flags = 0;
resp.reqack.head.events = 0;
if (0 <= ret)
{
@ -1201,6 +1203,7 @@ prepare:
resp.reqack.xid = req->head.xid;
resp.reqack.head.msgid = USRSOCK_MESSAGE_RESPONSE_DATA_ACK;
resp.reqack.head.flags = 0;
resp.reqack.head.events = 0;
if (0 == ret)
{
@ -1389,6 +1392,7 @@ prepare:
resp.reqack.xid = req->head.xid;
resp.reqack.head.msgid = USRSOCK_MESSAGE_RESPONSE_DATA_ACK;
resp.reqack.head.flags = 0;
resp.reqack.head.events = 0;
resp.reqack.result = ret;
if (0 == ret)
@ -1473,6 +1477,7 @@ prepare:
resp.reqack.xid = req->head.xid;
resp.reqack.head.msgid = USRSOCK_MESSAGE_RESPONSE_DATA_ACK;
resp.reqack.head.flags = 0;
resp.reqack.head.events = 0;
resp.reqack.result = ret;
if (0 == ret)
@ -1577,6 +1582,7 @@ static int ioctl_request(int fd, FAR struct gs2200m_s *priv,
resp2.reqack.xid = req->head.xid;
resp2.reqack.head.msgid = USRSOCK_MESSAGE_RESPONSE_DATA_ACK;
resp2.reqack.head.flags = 0;
resp2.reqack.head.events = 0;
resp2.valuelen_nontrunc = sizeof(imsg.ifr);
resp2.valuelen = sizeof(imsg.ifr);