Skip to content

Conversation

@willmmiles
Copy link

Calling AsyncClient::abort() will now enqueue an error event, as it did prior to #79. This fixes memory leaks caused by missing dispose callbacks.

This is an alternative to #81, which differs in that it calls the dispose callback inline in the AsyncClient::abort() context instead. I suggest this approach as it is the original semantic of the AsyncTCP library, and involves less code.

Calling `AsyncClient::abort()` will now enqueue an error event, as it
did prior to me-no-dev#79.  This fixes memory leaks caused by missing dispose
callbacks.
@willmmiles
Copy link
Author

One interesting fact about this implementation is that it doesn't need to think about purging the queue in abort() -- if there was already a closing operation queued, abort() is a no-op (_pcb is already nullptr) and that operation then completes and calls dispose; if not, tcp_abort() calls AsyncTCP_detail::tcp_error and we get one queued for us, and that event will handle the dispose.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR restores the original abort dispose semantics by ensuring that AsyncClient::abort() enqueues an error event instead of suppressing it. This fixes memory leaks that occurred when dispose callbacks were not properly triggered after PR #79.

Key changes:

  • Simplifies the _tcp_abort_api function by removing callback reset logic and event removal
  • Changes error handling to return ERR_ABRT for successful aborts instead of ERR_OK
  • Streamlines the AsyncClient::abort() method to directly return the abort result
Comments suppressed due to low confidence (1)

src/AsyncTCP.cpp:922

  • The closing brace for the abort() function is misplaced. It should come after the return statement, not before the comment about _pcb being NULL.
}

// _pcb is now NULL
}
return ERR_ABRT;
return _tcp_abort(&_pcb, this);
Copy link

Copilot AI Aug 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The return statement is missing proper formatting - it should be indented and the function should have a proper closing brace. The current code appears to have a formatting issue that could cause compilation errors.

Copilot uses AI. Check for mistakes.
@mathieucarbou
Copy link
Member

Thanks a lot @willmmiles ! I will close the other pr as the correct fix was much more complex than I anticipated 😅🙂

@mathieucarbou mathieucarbou merged commit b5e348c into ESP32Async:main Aug 2, 2025
23 checks passed
@mathieucarbou
Copy link
Member

@willmmiles : FYI I've sent you an invite to be part of the ESP32Async team. Feel free to accept or not as you wish: I know you are very busy... If you are on Discord, I could also add you to the maintainers channel. You could ping me with your username if you wish to do so. Thanks a lot for your help!

@willmmiles
Copy link
Author

@willmmiles : FYI I've sent you an invite to be part of the ESP32Async team. Feel free to accept or not as you wish: I know you are very busy... If you are on Discord, I could also add you to the maintainers channel. You could ping me with your username if you wish to do so. Thanks a lot for your help!

Thank you! I'm happy to help out where I can. Thank you guys for bearing with all the new bugs. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants