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

This commit is contained in:
Fedor 2019-05-20 09:01:29 +03:00
parent 88c1cf71f7
commit 6db7e1fcbb
1 changed files with 10 additions and 1 deletions

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).