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

Cleaning up client session arch to stop frag crash. #56

Merged
merged 6 commits into from
Aug 1, 2023

Conversation

GhostofCookie
Copy link
Contributor

@GhostofCookie GhostofCookie commented Jul 27, 2023

A bit of context here: The crashes around notify_pub_fragment (an example shown in Quicr/quicr-mac#152) seem to be caused by a race with deleting entries from the sub_delegates map, and trying to access the whole map in the notify.

A few things here:

  • The subscribe_state map was being fully emptied by both the QuicrClientRawSession and QuicrClientTransportDelegate destructors, which doesn't make a whole lot of sense.
  • The QuicrClientTransportDelegate was acting as a hollow shell of the session itself (one could argue this was the point of a delegate), but didn't actually do any real work itself, just turned around and called the session to do the work anyways (not very delegate-like).

The changes here:

  • QuicrRawClientSession becomes the TransportDelegate itself, so it doesn't abstract away calls to itself to a member owned by it (which consequently also stored a reference to the session, very circular).
  • The order of the members in the QuicrRawClientSession class are reordered to ensure a more proper teardown order (removing the need to explicitly call reset on a pointer).
  • Changing up connection status handling a little bit, and allowing a stop to be added to cancel connecting.

@GhostofCookie GhostofCookie marked this pull request as draft July 27, 2023 01:40
@GhostofCookie GhostofCookie marked this pull request as ready for review July 27, 2023 19:09
Comment on lines -165 to +128
while (transport->status() == qtransport::TransportStatus::Connecting) {
std::ostringstream log_msg;
log_msg << "Waiting for client to be ready, got: "
<< int(transport->status());
logger.log(qtransport::LogLevel::info, log_msg.str());
while (!stopping && client_status == ClientStatus::CONNECTING) {
std::this_thread::sleep_for(std::chrono::milliseconds(100));
}

client_status = ClientStatus::READY;
if (stopping) {
log_handler.log(qtransport::LogLevel::info,
(std::ostringstream() << "Cancelling connecting session "
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Though we try hard, picoquic (and even harder, UDP) decide that they don't want to be stopped, and continue on without a care. So fully stopping this when we want to leave a call if we didn't connect is a bit of an issue.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Both UDP and QUIC transports should be completely stopped if destructed. There's no shutdown method in the transport, which we should add... in a different PR unless you want to add it to this one.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Created #57 for this.

Copy link
Collaborator

@TimEvens TimEvens left a comment

Choose a reason for hiding this comment

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

LGTM

Comment on lines -165 to +128
while (transport->status() == qtransport::TransportStatus::Connecting) {
std::ostringstream log_msg;
log_msg << "Waiting for client to be ready, got: "
<< int(transport->status());
logger.log(qtransport::LogLevel::info, log_msg.str());
while (!stopping && client_status == ClientStatus::CONNECTING) {
std::this_thread::sleep_for(std::chrono::milliseconds(100));
}

client_status = ClientStatus::READY;
if (stopping) {
log_handler.log(qtransport::LogLevel::info,
(std::ostringstream() << "Cancelling connecting session "
Copy link
Collaborator

Choose a reason for hiding this comment

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

Both UDP and QUIC transports should be completely stopped if destructed. There's no shutdown method in the transport, which we should add... in a different PR unless you want to add it to this one.

src/quicr_client_raw_session.cpp Show resolved Hide resolved
@GhostofCookie GhostofCookie merged commit eb24b8e into main Aug 1, 2023
2 checks passed
@GhostofCookie GhostofCookie deleted the fix-fragmentation-crash branch August 1, 2023 17:34
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.

3 participants