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)
@ -377,8 +377,9 @@ static int socket_request(int fd, FAR struct daemon_priv_s *priv,
/* Prepare response. */
resp.head.msgid = USRSOCK_MESSAGE_RESPONSE_ACK;
resp.head.flags = 0;
resp.head.msgid = USRSOCK_MESSAGE_RESPONSE_ACK;
resp.head.flags = 0;
resp.head.events = 0;
resp.xid = req->head.xid;
resp.result = socketid;
@ -413,7 +414,8 @@ static int close_request(int fd, FAR struct daemon_priv_s *priv,
/* Prepare response. */
resp.head.msgid = USRSOCK_MESSAGE_RESPONSE_ACK;
resp.head.msgid = USRSOCK_MESSAGE_RESPONSE_ACK;
resp.head.events = 0;
resp.xid = req->head.xid;
if (priv->conf->delay_all_responses)
{
@ -551,8 +553,9 @@ prepare:
/* Prepare response. */
resp.xid = req->head.xid;
resp.head.msgid = USRSOCK_MESSAGE_RESPONSE_ACK;
resp.head.flags = 0;
resp.head.msgid = USRSOCK_MESSAGE_RESPONSE_ACK;
resp.head.flags = 0;
resp.head.events = 0;
if (priv->conf->endpoint_block_connect)
{
@ -744,8 +747,9 @@ prepare:
/* Prepare response. */
resp.xid = req->head.xid;
resp.head.msgid = USRSOCK_MESSAGE_RESPONSE_ACK;
resp.head.flags = 0;
resp.head.msgid = USRSOCK_MESSAGE_RESPONSE_ACK;
resp.head.flags = 0;
resp.head.events = 0;
if (priv->conf->delay_all_responses)
{
@ -880,8 +884,9 @@ prepare:
/* Prepare response. */
resp.reqack.xid = req->head.xid;
resp.reqack.head.msgid = USRSOCK_MESSAGE_RESPONSE_DATA_ACK;
resp.reqack.head.flags = 0;
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)
{
@ -1071,8 +1076,9 @@ prepare:
/* Prepare response. */
resp.xid = req->head.xid;
resp.head.msgid = USRSOCK_MESSAGE_RESPONSE_ACK;
resp.head.flags = 0;
resp.head.msgid = USRSOCK_MESSAGE_RESPONSE_ACK;
resp.head.flags = 0;
resp.head.events = 0;
if (priv->conf->delay_all_responses)
{
@ -1177,8 +1183,9 @@ prepare:
/* Prepare response. */
resp.reqack.xid = req->head.xid;
resp.reqack.head.msgid = USRSOCK_MESSAGE_RESPONSE_DATA_ACK;
resp.reqack.head.flags = 0;
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)
{
@ -1288,8 +1295,9 @@ prepare:
/* Prepare response. */
resp.reqack.xid = req->head.xid;
resp.reqack.head.msgid = USRSOCK_MESSAGE_RESPONSE_DATA_ACK;
resp.reqack.head.flags = 0;
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

@ -145,8 +145,9 @@ static int usrsock_rpmsg_send_ack(struct rpmsg_endpoint *ept,
{
struct usrsock_message_req_ack_s ack;
ack.head.msgid = USRSOCK_MESSAGE_RESPONSE_ACK;
ack.head.flags = (result == -EINPROGRESS);
ack.head.msgid = USRSOCK_MESSAGE_RESPONSE_ACK;
ack.head.flags = (result == -EINPROGRESS);
ack.head.events = 0;
ack.xid = xid;
ack.result = result;
@ -160,8 +161,9 @@ static int usrsock_rpmsg_send_data_ack(struct rpmsg_endpoint *ept,
uint16_t valuelen,
uint16_t valuelen_nontrunc)
{
ack->reqack.head.msgid = USRSOCK_MESSAGE_RESPONSE_DATA_ACK;
ack->reqack.head.flags = 0;
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;
@ -188,11 +190,11 @@ static int usrsock_rpmsg_send_event(struct rpmsg_endpoint *ept,
{
struct usrsock_message_socket_event_s event;
event.head.msgid = USRSOCK_MESSAGE_SOCKET_EVENT;
event.head.flags = USRSOCK_MESSAGE_FLAG_EVENT;
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

@ -246,8 +246,9 @@ static int _send_ack_common(int fd,
uint64_t xid,
FAR struct usrsock_message_req_ack_s *resp)
{
resp->head.msgid = USRSOCK_MESSAGE_RESPONSE_ACK;
resp->head.flags = 0;
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));
}
@ -951,8 +952,9 @@ prepare:
memset(&resp, 0, sizeof(resp));
resp.reqack.result = ret;
resp.reqack.xid = req->head.xid;
resp.reqack.head.msgid = USRSOCK_MESSAGE_RESPONSE_DATA_ACK;
resp.reqack.head.flags = 0;
resp.reqack.head.msgid = USRSOCK_MESSAGE_RESPONSE_DATA_ACK;
resp.reqack.head.flags = 0;
resp.reqack.head.events = 0;
if (0 <= ret)
{
@ -1199,8 +1201,9 @@ prepare:
memset(&resp, 0, sizeof(resp));
resp.reqack.xid = req->head.xid;
resp.reqack.head.msgid = USRSOCK_MESSAGE_RESPONSE_DATA_ACK;
resp.reqack.head.flags = 0;
resp.reqack.head.msgid = USRSOCK_MESSAGE_RESPONSE_DATA_ACK;
resp.reqack.head.flags = 0;
resp.reqack.head.events = 0;
if (0 == ret)
{
@ -1387,8 +1390,9 @@ prepare:
memset(&resp, 0, sizeof(resp));
resp.reqack.xid = req->head.xid;
resp.reqack.head.msgid = USRSOCK_MESSAGE_RESPONSE_DATA_ACK;
resp.reqack.head.flags = 0;
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)
@ -1471,8 +1475,9 @@ prepare:
memset(&resp, 0, sizeof(resp));
resp.reqack.xid = req->head.xid;
resp.reqack.head.msgid = USRSOCK_MESSAGE_RESPONSE_DATA_ACK;
resp.reqack.head.flags = 0;
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)
@ -1575,8 +1580,9 @@ static int ioctl_request(int fd, FAR struct gs2200m_s *priv,
{
resp2.reqack.result = ret;
resp2.reqack.xid = req->head.xid;
resp2.reqack.head.msgid = USRSOCK_MESSAGE_RESPONSE_DATA_ACK;
resp2.reqack.head.flags = 0;
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);