Bug 1521304: Move some Mutexes r=tuexen,dminor a=lizzard
authorRandell Jesup <rjesup@jesup.org>
Tue, 12 Feb 2019 07:28:27 -0500
changeset 515946 35e4f7994c010a09d9edeb3889b43508de71177e
parent 515945 720c87f798e304851f72f5ac6fc90d21d1239a38
child 515947 103d75c41ada928c667803e4e64983d8958febea
push id1953
push userffxbld-merge
push dateMon, 11 Mar 2019 12:10:20 +0000
treeherdermozilla-release@9c35dcbaa899 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstuexen, dminor, lizzard
bugs1521304
milestone66.0
Bug 1521304: Move some Mutexes r=tuexen,dminor a=lizzard
netwerk/sctp/datachannel/DataChannel.cpp
--- a/netwerk/sctp/datachannel/DataChannel.cpp
+++ b/netwerk/sctp/datachannel/DataChannel.cpp
@@ -2308,22 +2308,31 @@ void DataChannelConnection::HandleNotifi
 int DataChannelConnection::ReceiveCallback(struct socket *sock, void *data,
                                            size_t datalen,
                                            struct sctp_rcvinfo rcv, int flags) {
   ASSERT_WEBRTC(!NS_IsMainThread());
 
   if (!data) {
     LOG(("ReceiveCallback: 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, flags);
     }
+    if (locked) {
+      mLock.Unlock();
+    }
   }
   // sctp allocates 'data' with malloc(), and expects the receiver to free
   // it (presumably with free).
   // XXX future optimization: try to deliver messages without an internal
   // alloc/copy, and if so delay the free until later.
   free(data);
   // usrsctp defines the callback as returning an int, but doesn't use it
   return 1;