WebRTC: Add explicit mutex on callback receiver for cases it's not

already locked.
This commit is contained in:
wolfbeast 2019-03-23 13:26:20 +01:00 committed by Roy Tam
commit f6f11db550

View file

@ -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<union sctp_notification *>(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).