From 9fc25801fdae8a88e2baa68bb500b24e53d9d8bf Mon Sep 17 00:00:00 2001 From: wolfbeast Date: Sat, 23 Mar 2019 13:26:20 +0100 Subject: WebRTC: Add explicit mutex on callback receiver for cases it's not already locked. --- netwerk/sctp/datachannel/DataChannel.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'netwerk/sctp') diff --git a/netwerk/sctp/datachannel/DataChannel.cpp b/netwerk/sctp/datachannel/DataChannel.cpp index ebc430f8c..19be43d1c 100644 --- a/netwerk/sctp/datachannel/DataChannel.cpp +++ b/netwerk/sctp/datachannel/DataChannel.cpp @@ -1928,12 +1928,21 @@ DataChannelConnection::ReceiveCallback(struct socket* sock, void *data, size_t d if (!data) { usrsctp_close(sock); // SCTP has finished shutting down } else { - mLock.AssertCurrentThreadOwns(); + bool locked = false; + if (!IsSTSThread()) { + mLock.Lock(); + locked = true; + } else { + mLock.AssertCurrentThreadOwns(); + } if (flags & MSG_NOTIFICATION) { HandleNotification(static_cast(data), datalen); } else { HandleMessage(data, datalen, ntohl(rcv.rcv_ppid), rcv.rcv_sid); } + if (locked) { + mLock.Unlock(); + } } // sctp allocates 'data' with malloc(), and expects the receiver to free // it (presumably with free). -- cgit v1.2.3