versatica / libmediasoupclient

mediasoup client side C++ library

Home Page:https://mediasoup.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

DataConsumer::Close() crash

binxie33 opened this issue · comments

In DataConsumer::Close() we should UnregisterObserver first before closing, otherwise it will crash.

         /**
	 * Closes the DataConsumer.
	 */
	void DataConsumer::Close()
	{
		MSC_TRACE();

		if (this->closed)
			return;

		this->closed = true;
		this->dataChannel->UnregisterObserver();  // here is the fix
		this->dataChannel->Close();
		this->privateListener->OnClose(this);
	}

does it actually crash currently?

This should not be needed, otherwise we won't get the 'close' state changed from the underlaying datachannel.

More than that, if we get events from the underlaying datachannel after closing it, that would be a but in libwebrtc.