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

Closing peer connection threads #121

Merged
merged 1 commit into from
Jun 9, 2021
Merged

Closing peer connection threads #121

merged 1 commit into from
Jun 9, 2021

Conversation

pablito25sp
Copy link
Contributor

When creating a new PeerConnection without a PeerConnectionFactory, network, signaling and worker threads are created.
After closing the peer connection, Handler will close those threads if they exist after receiving the OnSignalingChange for "close" state.

When creating a new PeerConnection without a PeerConnectionFactory, network, signaling and worker threads are created.
After closing the peer connection, Handler will close those threads if they exist after receiving the OnSignalingChange for "close" state.
Copy link
Member

@ibc ibc left a comment

Choose a reason for hiding this comment

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

I like it. @jmillan?

@jmillan jmillan merged commit fe69a74 into versatica:v3 Jun 9, 2021
@jmillan
Copy link
Member

jmillan commented Jun 9, 2021

Thanks @pablito25sp!

@pablito25sp
Copy link
Contributor Author

You're welcome! Great work of all of you 👏🏻

@jmillan
Copy link
Member

jmillan commented Jun 9, 2021

@pablito25sp,

The tests hang up for ever after this change.

If I kill the process it seems that OnTransportClose was never fired.

Please take a look at it.

Screenshot 2021-06-09 at 16 55 31

NOTE: The test binary resides in build/test/ directory.

@pablito25sp
Copy link
Contributor Author

Ok.. Will do. I did not run the test obviously, sorry about that.
Anyway it's something weird because on my implementation, callbacks are correctly triggered.
I will let you know.

@pablito25sp
Copy link
Contributor Author

Hey guys, I'm not being able to run tests on my laptop (an M1).

Screen Shot 2021-06-09 at 19 09 57

And about what I've said before about the callbacks being triggered, I was not accurate. I'm triggering callbacks on my implementation when receiving the OnConnectionStateChange.

I've found some similar issues here: https://stackoverflow.com/questions/51275714/webrtc-peerconnectionfactory-graceful-shutdown

My question is, would be appropriate to move producer->TransportClosed(); out of SendTransport::Close() (same for RecvTransport::Close()) in Transport.cpp? And effectively call those callbacks when Handler receives (and pass to the Transport) the closed state?

I can update the PR with this if it makes sense for you.

@jmillan
Copy link
Member

jmillan commented Jun 10, 2021

Hi @pablito25sp,

Deleting the threads on PeerConnection destructor is fine. We are creating them on construction, and doing the oposite on destruction will remove any leak and be consistent.

In your approach it seems that PeerConnection::Close() gets blocked if the signaling thread has been removed before.

@jmillan
Copy link
Member

jmillan commented Jun 10, 2021

Could you try the threads removal on PeerConnection destructor?

jmillan added a commit that referenced this pull request Jun 10, 2021
@jmillan
Copy link
Member

jmillan commented Jun 10, 2021

I've reverted the commit from v3 for now.

@jmillan
Copy link
Member

jmillan commented Jun 10, 2021

Regarding to the use-after-free, yes, we need to run valgrind on the the tests. Thanks for the reminder!

@pablito25sp
Copy link
Contributor Author

Could you try the threads removal on PeerConnection destructor?

Will do. Thanks for the hint.

@pablito25sp
Copy link
Contributor Author

Opened a new one: #122
Instead of writing a destructor, I've just assigned nullptr to the threads when constructor is called without PeerConnection::Options. Looks clearer to me.

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

Successfully merging this pull request may close these issues.

3 participants