Bug 1421963: lock around SCTP input processing, not just the receive callback r=drno
authorRandell Jesup <rjesup@jesup.org>
Thu, 07 Dec 2017 13:24:46 -0500
changeset 395638 82f6a0139402245a07f1e05e4bebd2861b78f4dd
parent 395637 e311eb750f43d22c4ea2e6ca8a65a9188b00402a
child 395639 115d70e6c818c34624e7b9a0a2a1579ad92f1b40
push id33049
push usercsabou@mozilla.com
push dateFri, 08 Dec 2017 09:57:17 +0000
treeherdermozilla-central@437bfd403b76 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdrno
bugs1421963
milestone59.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1421963: lock around SCTP input processing, not just the receive callback r=drno
netwerk/sctp/datachannel/DataChannel.cpp
--- a/netwerk/sctp/datachannel/DataChannel.cpp
+++ b/netwerk/sctp/datachannel/DataChannel.cpp
@@ -812,16 +812,17 @@ DataChannelConnection::SctpDtlsInput(Tra
     char *buf;
 
     if ((buf = usrsctp_dumppacket((void *)data, len, SCTP_DUMP_INBOUND)) != nullptr) {
       SCTP_LOG(("%s", buf));
       usrsctp_freedumpbuffer(buf);
     }
   }
   // Pass the data to SCTP
+  MutexAutoLock lock(mLock);
   usrsctp_conninput(static_cast<void *>(this), data, len, 0);
 }
 
 int
 DataChannelConnection::SendPacket(unsigned char data[], size_t len, bool release)
 {
   //LOG(("%p: SCTP/DTLS sent %ld bytes", this, len));
   int res = mTransportFlow->SendPacket(data, len) < 0 ? 1 : 0;
@@ -1219,17 +1220,17 @@ DataChannelConnection::SendOpenRequestMe
 
 // returns if we're still blocked (true)
 bool
 DataChannelConnection::SendDeferredMessages()
 {
   RefPtr<DataChannel> channel; // we may null out the refs to this
 
   // This may block while something is modifying channels, but should not block for IO
-  MutexAutoLock lock(mLock);
+  mLock.AssertCurrentThreadOwns();
 
   LOG(("SendDeferredMessages called, pending type: %d", mPendingType));
   if (!mPendingType) {
     return false;
   }
 
   // Send pending control messages
   // Note: If ndata is not active, check if DCEP messages are currently outstanding. These need to
@@ -2302,17 +2303,17 @@ int
 DataChannelConnection::ReceiveCallback(struct socket* sock, void *data, size_t datalen,
                                        struct sctp_rcvinfo rcv, int flags)
 {
   ASSERT_WEBRTC(!NS_IsMainThread());
 
   if (!data) {
     usrsctp_close(sock); // SCTP has finished shutting down
   } else {
-    MutexAutoLock lock(mLock);
+    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);
     }
   }
   // sctp allocates 'data' with malloc(), and expects the receiver to free
   // it (presumably with free).