From c75253623d60fb034670e0921642caa1b339db9e Mon Sep 17 00:00:00 2001 From: liangchaozhong Date: Fri, 16 Sep 2022 18:43:34 +0800 Subject: [PATCH] usrsock:fix blocking socket connect operation hang issue Issue description: usrsock will wait for state.recvsem forever because no event triggers state.recvsem post operation when connect operation in server side is non-blocking. Solution: trigger state.recvsem post operation after receive USRSOCK_EVENT_SENDTO_READY. Signed-off-by: liangchaozhong --- net/usrsock/usrsock_connect.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/net/usrsock/usrsock_connect.c b/net/usrsock/usrsock_connect.c index 6e40fc0eb1..7793f6847a 100644 --- a/net/usrsock/usrsock_connect.c +++ b/net/usrsock/usrsock_connect.c @@ -65,7 +65,7 @@ static uint16_t connect_event(FAR struct net_driver_s *dev, nxsem_post(&pstate->recvsem); } - else if (flags & USRSOCK_EVENT_REQ_COMPLETE) + else { ninfo("request completed.\n"); @@ -199,7 +199,8 @@ int usrsock_connect(FAR struct socket *psock, ret = usrsock_setup_request_callback(conn, &state, connect_event, USRSOCK_EVENT_ABORT | - USRSOCK_EVENT_REQ_COMPLETE); + USRSOCK_EVENT_REQ_COMPLETE | + USRSOCK_EVENT_SENDTO_READY); if (ret < 0) { nwarn("usrsock_setup_request_callback failed: %d\n", ret);