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(). |
||
---|---|---|
.. | ||
FEATURE_BLE | ||
FEATURE_COMMON_PAL | ||
FEATURE_LWIP | ||
FEATURE_UVISOR | ||
frameworks | ||
mbedtls | ||
nanostack | ||
netsocket | ||
storage/FEATURE_STORAGE | ||
unsupported |