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

Resolve some issues with (DTLS) session management and add some tests. #8

Merged
merged 4 commits into from
May 18, 2023

Conversation

pulsastrix
Copy link
Member

@pulsastrix pulsastrix commented Feb 3, 2023

This PR resolves a number of smaller issues with DTLS support and adds a basic DTLS test, refactoring out common parts between the UDP and DTLS test cases.

The following issues were resolved:

  • Dropping a context that has an active DTLS session caused a panic because dropping the session would trigger the event handler, which could not obtain a reference to the context as it was not lent. To solve this, the event handler is now disabled when the context is dropped (I assume you wouldn't handle events in that case anyways).
  • The UseCurrent response for CoapServerCryptoProviders wasn't handled properly: The handler did not consider the correct key.

There is still one more issue that remains to be resolved: Currently, client-side sessions are kept in memory until the context is dropped, and not doing so causes some more crashes because the event handler is then called on a session that is in the process of being dropped. I'll look into that problem in the next few days.
Update: Is now fixed by temporarily disabling the event handler in the client side session drop implementation.

@pulsastrix pulsastrix mentioned this pull request Feb 3, 2023
@pulsastrix pulsastrix self-assigned this Feb 3, 2023
@pulsastrix pulsastrix linked an issue Feb 3, 2023 that may be closed by this pull request
Before this commit, client-side sessions were kept in a Vec inside of
the CoapContext for the entire lifetime of the context instead of
freeing them as soon as they were dropped.

This commit fixes the issue by fixing the Drop implementation of
CoapClientSessionInner, which caused a SIGABRT if it was called outside
of the CoapContext drop handler.

Additionally, client-side sessions are no longer stored in the
CoapContext, as they were not used there except for in the Drop
implementation, which is no longer necessary due to the aforementioned
fix.
@pulsastrix pulsastrix marked this pull request as ready for review May 18, 2023 03:52
@pulsastrix pulsastrix requested a review from falko17 May 18, 2023 04:02
Copy link
Member

@falko17 falko17 left a comment

Choose a reason for hiding this comment

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

Looks good, though note that I did not review test code.

@pulsastrix pulsastrix merged commit 1df5fb2 into main May 18, 2023
@pulsastrix pulsastrix deleted the dtls_context_drop_panic branch May 22, 2023 22:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bug when using dtls?
2 participants