Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: atserver_connection should not be disconnected during free #555

Open
XavierChanth opened this issue Feb 7, 2025 · 0 comments
Open
Assignees
Labels
bug Something isn't working

Comments

@XavierChanth
Copy link
Member

XavierChanth commented Feb 7, 2025

atserver_connection_free also closes the socket, which means that if you have multiple references to an atserver_connection, such as when you fork a process. Then the first call to free will disconnect and free as intended. Every subsequent attempt to use this connection will then fail as the program state thinks its connected when its not.

Generally also, you don't want to disconnect the socket until the last instance has been closed. These actions shouldn't be coupled together. The reason for this is the underlying memory that was cloned is pointed at the same file descriptor for the socket.

The TLS socket layer doesn't have this coupled behavior, only the atserver_connection code does.

Edit: actually, TLS socket layer does have this behavior, as a result of mbedtls_net_free having this behavior. Enhancement request filed with mbedtls: Mbed-TLS/mbedtls#9958

@XavierChanth XavierChanth added the bug Something isn't working label Feb 7, 2025
@XavierChanth XavierChanth self-assigned this Feb 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant