Skip to content

Commit

Permalink
usrsock_server: combine response and events when socket setup case
Browse files Browse the repository at this point in the history
Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
  • Loading branch information
zhhyu7 authored and masayuki2009 committed Oct 14, 2022
1 parent 8a2f29c commit 6e8ea78
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions netutils/usrsock_rpmsg/usrsock_rpmsg_server.c
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,7 @@ static int usrsock_rpmsg_socket_handler(struct rpmsg_endpoint *ept,
{
struct usrsock_request_socket_s *req = data;
struct usrsock_rpmsg_s *priv = priv_;
uint16_t events = 0;
int i;
int retr;
int ret = -ENFILE;
Expand All @@ -250,6 +251,10 @@ static int usrsock_rpmsg_socket_handler(struct rpmsg_endpoint *ept,
{
priv->epts[i] = ept;
ret = i; /* Return index as the usockid */
if (req->type != SOCK_STREAM && req->type != SOCK_SEQPACKET)
{
events = USRSOCK_EVENT_SENDTO_READY;
}
}

break;
Expand All @@ -258,7 +263,7 @@ static int usrsock_rpmsg_socket_handler(struct rpmsg_endpoint *ept,
pthread_mutex_unlock(&priv->mutex);
}

retr = usrsock_rpmsg_send_ack(ept, 0, req->head.xid, ret);
retr = usrsock_rpmsg_send_ack(ept, events, req->head.xid, ret);
if (retr >= 0 && ret >= 0 &&
req->type != SOCK_STREAM && req->type != SOCK_SEQPACKET)
{
Expand All @@ -267,7 +272,6 @@ static int usrsock_rpmsg_socket_handler(struct rpmsg_endpoint *ept,
priv->pfds[ret].events = POLLIN;
usrsock_rpmsg_notify_poll(priv);
pthread_mutex_unlock(&priv->mutex);
retr = usrsock_rpmsg_send_event(ept, ret, USRSOCK_EVENT_SENDTO_READY);
}

return retr;
Expand Down

0 comments on commit 6e8ea78

Please sign in to comment.