mirror of https://github.com/ARMmbed/mbed-os.git
It's currently possible to generate a socket event when a non-blocking socket is closed: 1. _pending is set to 0 in https://github.com/ARMmbed/mbed-os/blob/master/features/netsocket/TCPSocket.cpp#L22 when the socket is created. 2. close() calls event() in https://github.com/ARMmbed/mbed-os/blob/master/features/netsocket/Socket.cpp#L66 3. event() increments _pending, and since _pending is 1 it will call _callback() in https://github.com/ARMmbed/mbed-os/blob/master/features/netsocket/TCPSocket.cpp#L167 However, if send() (for example) is called, this can happen: - send() is called and sets _pending to 0. - when the data is sent, event() is called, which sets _pending to 1 and calls _callback(). - if close() is called at this point, there won't be an event generated for close() anymore, since _pending will be set to 2. Same thing for recv. Also, same thing for TCPServer and UDPSocket. This PR changes the initial value of _pending to 1 instead of 0, so that events are never generated for close(). |
||
---|---|---|
.. | ||
CellularInterface.h | ||
EthInterface.h | ||
MeshInterface.h | ||
NetworkInterface.cpp | ||
NetworkInterface.h | ||
NetworkStack.cpp | ||
NetworkStack.h | ||
Socket.cpp | ||
Socket.h | ||
SocketAddress.cpp | ||
SocketAddress.h | ||
TCPServer.cpp | ||
TCPServer.h | ||
TCPSocket.cpp | ||
TCPSocket.h | ||
UDPSocket.cpp | ||
UDPSocket.h | ||
WiFiAccessPoint.cpp | ||
WiFiAccessPoint.h | ||
WiFiInterface.h | ||
emac_stack_mem.h | ||
mbed_lib.json | ||
nsapi.h | ||
nsapi_dns.cpp | ||
nsapi_dns.h | ||
nsapi_types.h |