Skip to content

Commit

Permalink
worker: Add Transport::Destroying() protected method (#1114)
Browse files Browse the repository at this point in the history
  • Loading branch information
ibc committed Jul 10, 2023
1 parent 9940300 commit 644e2a4
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 3 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
# Changelog


### Next

* `Worker`: Add `Transport::Destroying()` protected method ([PR #1114](https://github.com/versatica/mediasoup/pull/1114)).


### 3.12.5

* `DataConsumer`: Fix removed 'bufferedamountlow' notification ([PR #1113](https://github.com/versatica/mediasoup/pull/1113)).
Expand Down
1 change: 1 addition & 0 deletions worker/include/RTC/Transport.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ namespace RTC

protected:
// Must be called from the subclass.
void Destroying();
void Connected();
void Disconnected();
void DataReceived(size_t len)
Expand Down
4 changes: 4 additions & 0 deletions worker/src/RTC/DirectTransport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ namespace RTC
{
MS_TRACE();

// Tell the Transport parent class that we are about to destroy
// the class instance.
Destroying();

this->shared->channelMessageRegistrator->UnregisterHandler(this->id);
}

Expand Down
4 changes: 4 additions & 0 deletions worker/src/RTC/PipeTransport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,10 @@ namespace RTC
{
MS_TRACE();

// Tell the Transport parent class that we are about to destroy
// the class instance.
Destroying();

this->shared->channelMessageRegistrator->UnregisterHandler(this->id);

delete this->udpSocket;
Expand Down
4 changes: 4 additions & 0 deletions worker/src/RTC/PlainTransport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,10 @@ namespace RTC
{
MS_TRACE();

// Tell the Transport parent class that we are about to destroy
// the class instance.
Destroying();

this->shared->channelMessageRegistrator->UnregisterHandler(this->id);

delete this->udpSocket;
Expand Down
10 changes: 7 additions & 3 deletions worker/src/RTC/Transport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -182,9 +182,6 @@ namespace RTC
{
MS_TRACE();

// Set the destroying flag.
this->destroying = true;

// The destructor must delete and clear everything silently.

// Delete all Producers.
Expand Down Expand Up @@ -1594,6 +1591,13 @@ namespace RTC
}
}

void Transport::Destroying()
{
MS_TRACE();

this->destroying = true;
}

void Transport::Connected()
{
MS_TRACE();
Expand Down
5 changes: 5 additions & 0 deletions worker/src/RTC/WebRtcTransport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,11 @@ namespace RTC
{
MS_TRACE();

// We need to tell the Transport parent class that we are about to destroy
// the class instance. This is because child's destructor runs before
// parent's destructor. See comment in Transport::OnSctpAssociationSendData().
Destroying();

this->shared->channelMessageRegistrator->UnregisterHandler(this->id);

// Must delete the DTLS transport first since it will generate a DTLS alert
Expand Down

0 comments on commit 644e2a4

Please sign in to comment.