Bug 876167: backout temporary fix for SCTP library bug (now fixed) r=tuexen
authorRandell Jesup <rjesup@jesup.org>
Wed, 12 Mar 2014 20:14:59 -0400
changeset 191517 7ada8c5a0480053a374dffc1afcac5dc1cce4467
parent 191516 8876cd22695be7bb62e9ba672bbe3a6bba6a714f
child 191518 ceb23e4d75545648b09456665cce9846b0fadbc0
push id474
push userasasaki@mozilla.com
push dateMon, 02 Jun 2014 21:01:02 +0000
treeherdermozilla-release@967f4cf1b31c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstuexen
bugs876167
milestone30.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 876167: backout temporary fix for SCTP library bug (now fixed) r=tuexen
netwerk/sctp/datachannel/DataChannel.cpp
netwerk/sctp/datachannel/DataChannel.h
--- a/netwerk/sctp/datachannel/DataChannel.cpp
+++ b/netwerk/sctp/datachannel/DataChannel.cpp
@@ -250,51 +250,42 @@ DataChannelConnection::Destroy()
   ASSERT_WEBRTC(NS_IsMainThread());
   CloseAll();
 
   MutexAutoLock lock(mLock);
   // If we had a pending reset, we aren't waiting for it - clear the list so
   // we can deregister this DataChannelConnection without leaking.
   ClearResets();
 
-  MOZ_ASSERT(mSTS);
-  ASSERT_WEBRTC(NS_IsMainThread());
-  // Finish Destroy on STS thread to avoid bug 876167 - once that's fixed,
-  // the usrsctp_close() calls can move back here (and just proxy the
-  // disconnect_all())
-  RUN_ON_THREAD(mSTS, WrapRunnable(nsRefPtr<DataChannelConnection>(this),
-                                   &DataChannelConnection::DestroyOnSTS,
-                                   mSocket, mMasterSocket),
-                NS_DISPATCH_NORMAL);
+  if (mSocket && mSocket != mMasterSocket)
+    usrsctp_close(mSocket);
+  if (mMasterSocket)
+    usrsctp_close(mMasterSocket);
 
-  // These will be released on STS
   mSocket = nullptr;
   mMasterSocket = nullptr; // also a flag that we've Destroyed this connection
 
-  // Must do this in Destroy() since we may then delete this object
   if (mUsingDtls) {
     usrsctp_deregister_address(static_cast<void *>(this));
     LOG(("Deregistered %p from the SCTP stack.", static_cast<void *>(this)));
   }
-
   // We can't get any more new callbacks from the SCTP library
   // All existing callbacks have refs to DataChannelConnection
 
   // nsDOMDataChannel objects have refs to DataChannels that have refs to us
-}
-
-void DataChannelConnection::DestroyOnSTS(struct socket *aMasterSocket,
-                                         struct socket *aSocket)
-{
-  if (aSocket && aSocket != aMasterSocket)
-    usrsctp_close(aSocket);
-  if (aMasterSocket)
-    usrsctp_close(aMasterSocket);
-
-  disconnect_all();
+  if (mTransportFlow) {
+    MOZ_ASSERT(mSTS);
+    ASSERT_WEBRTC(NS_IsMainThread());
+    RUN_ON_THREAD(mSTS, WrapRunnable(nsRefPtr<DataChannelConnection>(this),
+                                     &DataChannelConnection::disconnect_all),
+                  NS_DISPATCH_NORMAL);
+    // don't release mTransportFlow until we are destroyed in case
+    // runnables are in flight.  We may well have packets to send as the
+    // SCTP lib may have sent a shutdown.
+  }
 }
 
 NS_IMPL_ISUPPORTS1(DataChannelConnection,
                    nsITimerCallback)
 
 bool
 DataChannelConnection::Init(unsigned short aPort, uint16_t aNumStreams, bool aUsingDtls)
 {
--- a/netwerk/sctp/datachannel/DataChannel.h
+++ b/netwerk/sctp/datachannel/DataChannel.h
@@ -118,19 +118,16 @@ public:
     virtual void NotifyDataChannel(already_AddRefed<DataChannel> channel) = 0;
   };
 
   DataChannelConnection(DataConnectionListener *listener);
   virtual ~DataChannelConnection();
 
   bool Init(unsigned short aPort, uint16_t aNumStreams, bool aUsingDtls);
   void Destroy(); // So we can spawn refs tied to runnables in shutdown
-  // Finish Destroy on STS to avoid SCTP race condition with ABORT from far end
-  void DestroyOnSTS(struct socket *aMasterSocket,
-                    struct socket *aSocket);
 
 #ifdef ALLOW_DIRECT_SCTP_LISTEN_CONNECT
   // These block; they require something to decide on listener/connector
   // (though you can do simultaneous Connect()).  Do not call these from
   // the main thread!
   bool Listen(unsigned short port);
   bool Connect(const char *addr, unsigned short port);
 #endif