Skip to content

Commit

Permalink
Merge pull request #953 from paullouisageneau/fix-dc-close-stream
Browse files Browse the repository at this point in the history
Fix DataChannel to reset stream on close if ack is not received
  • Loading branch information
paullouisageneau authored Sep 1, 2023
2 parents 853c4c0 + 025fffe commit 2223434
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
9 changes: 5 additions & 4 deletions src/impl/datachannel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,12 @@ void DataChannel::close() {
transport = mSctpTransport.lock();
}

if (mIsOpen.exchange(false) && transport && mStream.has_value())
transport->closeStream(mStream.value());
if (!mIsClosed.exchange(true)) {
if (transport && mStream.has_value())
transport->closeStream(mStream.value());

if (!mIsClosed.exchange(true))
triggerClosed();
}

resetCallbacks();
}
Expand Down Expand Up @@ -140,7 +141,7 @@ Reliability DataChannel::reliability() const {
return *mReliability;
}

bool DataChannel::isOpen(void) const { return mIsOpen; }
bool DataChannel::isOpen(void) const { return !mIsClosed && mIsOpen; }

bool DataChannel::isClosed(void) const { return mIsClosed; }

Expand Down
2 changes: 1 addition & 1 deletion src/impl/peerconnection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,7 @@ void PeerConnection::forwardMessage(message_ptr message) {
if (found) {
// The stream is already used, the receiver must close the DataChannel
PLOG_WARNING << "Got open message on already used stream " << stream;
if(channel && channel->isOpen())
if(channel && !channel->isClosed())
channel->close();
else
sctpTransport->closeStream(message->stream);
Expand Down

0 comments on commit 2223434

Please sign in to comment.