versatica / libmediasoupclient

mediasoup client side C++ library
https://mediasoup.org
ISC License
291 stars 178 forks source link

DataConsumer::Close() crash #94

Closed binxie33 closed 2 years ago

binxie33 commented 4 years ago

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);
    }
jmillan commented 2 years ago

does it actually crash currently?

jmillan commented 2 years ago

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.