From 8c555239212ca31160df633fa1e68c5a3c46852b Mon Sep 17 00:00:00 2001 From: Vincent Coubard Date: Mon, 28 Jun 2021 16:31:03 +0100 Subject: [PATCH] Mark UDP socket as ready for write in send msg. (#7927) When SendMsg is called, it may create a new socket which is not part of the files monitored by the system. The FD won't be added to this list until select (or other monitoring mechanism) unblock. This patch ensure that a socket created with SendMsg is added immediately to the list of FD being monitored. It mirrors what is done in the Listen function. --- src/inet/UDPEndPoint.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/inet/UDPEndPoint.cpp b/src/inet/UDPEndPoint.cpp index 0af80423861c81..1c539697b3787a 100644 --- a/src/inet/UDPEndPoint.cpp +++ b/src/inet/UDPEndPoint.cpp @@ -649,6 +649,10 @@ INET_ERROR UDPEndPoint::SendMsg(const IPPacketInfo * pktInfo, System::PacketBuff SuccessOrExit(res); res = IPEndPointBasis::SendMsg(pktInfo, std::move(msg), sendFlags); + + // Wait for ability to write on this endpoint. + mSocket.SetCallback(HandlePendingIO, reinterpret_cast(this)); + mSocket.OnRequestCallbackOnPendingWrite(); #endif // CHIP_SYSTEM_CONFIG_USE_SOCKETS #if CHIP_SYSTEM_CONFIG_USE_NETWORK_FRAMEWORK