Merge pull request #8336 from sentinelt/socket-closed

Fix hard-fault when socket created using accept() is closed
pull/8222/merge
Cruz Monrreal 2018-10-15 10:22:17 -05:00 committed by GitHub
commit 00f8ecfb7a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 0 deletions

View File

@ -222,6 +222,7 @@ TEST_F(TestInternetSocket, getsockopt)
TEST_F(TestInternetSocket, sigio)
{
callback_is_called = false;
socket->open((NetworkStack *)&stack);
socket->sigio(mbed::callback(my_callback));
socket->close(); // Trigger event;
EXPECT_EQ(callback_is_called, true);

View File

@ -56,6 +56,10 @@ nsapi_error_t InternetSocket::close()
_lock.lock();
nsapi_error_t ret = NSAPI_ERROR_OK;
if (!_stack) {
return ret;
}
if (_socket) {
_stack->socket_attach(_socket, 0, 0);
nsapi_socket_t socket = _socket;