From 6e8ea78d70a6b62704ac0bbc1d37e57984ad0c23 Mon Sep 17 00:00:00 2001 From: zhanghongyu Date: Sat, 8 Oct 2022 10:54:12 +0800 Subject: [PATCH] usrsock_server: combine response and events when socket setup case Signed-off-by: zhanghongyu --- netutils/usrsock_rpmsg/usrsock_rpmsg_server.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/netutils/usrsock_rpmsg/usrsock_rpmsg_server.c b/netutils/usrsock_rpmsg/usrsock_rpmsg_server.c index 46b8f0c43..dd37df9b0 100644 --- a/netutils/usrsock_rpmsg/usrsock_rpmsg_server.c +++ b/netutils/usrsock_rpmsg/usrsock_rpmsg_server.c @@ -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; @@ -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; @@ -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) { @@ -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;