Skip to content

Commit

Permalink
Mark UDP socket as ready for write in send msg. (project-chip#7927)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
pan- authored Jun 28, 2021
1 parent fead7d1 commit 8c55523
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/inet/UDPEndPoint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<intptr_t>(this));
mSocket.OnRequestCallbackOnPendingWrite();
#endif // CHIP_SYSTEM_CONFIG_USE_SOCKETS

#if CHIP_SYSTEM_CONFIG_USE_NETWORK_FRAMEWORK
Expand Down

0 comments on commit 8c55523

Please sign in to comment.