Backed out changeset f3c055585a4f (bug 843857) for B2G mochitest bustage.
authorRyan VanderMeulen <ryanvm@gmail.com>
Fri, 24 Jan 2014 17:19:52 -0500
changeset 165160 eb8c4ec52bc0fb1446efc222a780e2dbe0693e77
parent 165158 765019ac7236420a6b26ecef7f8fb0fea8efc732
child 165161 0b8da53fb0c1646f3773921f4b13060b24716a73
child 165191 9e06d42c2a6ad84eb6b701105b544cf031fad0b9
child 165215 88c332b7c8758593aefc5dc28c225197772c9e00
child 165240 d1602db7c9043d64bc633ea9bf3c0d1149e46273
child 166159 4c416e24b73c359071bddcae2206925f538f112e
push id38899
push userryanvm@gmail.com
push dateFri, 24 Jan 2014 22:22:17 +0000
treeherdermozilla-inbound@0b8da53fb0c1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs843857
milestone29.0a1
backs outf3c055585a4fb0bfa92be62f43512fa5d093431d
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
Backed out changeset f3c055585a4f (bug 843857) for B2G mochitest bustage.
ipc/unixsocket/UnixSocket.cpp
--- a/ipc/unixsocket/UnixSocket.cpp
+++ b/ipc/unixsocket/UnixSocket.cpp
@@ -169,19 +169,16 @@ public:
   /**
    * Consumer pointer. Non-thread safe RefPtr, so should only be manipulated
    * directly from main thread. All non-main-thread accesses should happen with
    * mImpl as container.
    */
   RefPtr<UnixSocketConsumer> mConsumer;
 
 private:
-
-  void FireSocketError();
-
   /**
    * libevent triggered functions that reads data from socket when available and
    * guarenteed non-blocking. Only to be called on IO thread.
    *
    * @param aFd File descriptor to read from
    */
   virtual void OnFileCanReadWithoutBlocking(int aFd);
 
@@ -485,132 +482,126 @@ void ShutdownSocketTask::Run()
   mImpl->ShutdownOnIOThread();
 
   nsRefPtr<nsIRunnable> t(new DeleteInstanceRunnable<UnixSocketImpl>(mImpl));
   nsresult rv = NS_DispatchToMainThread(t);
   NS_ENSURE_SUCCESS_VOID(rv);
 }
 
 void
-UnixSocketImpl::FireSocketError()
+UnixSocketImpl::Accept()
 {
   MOZ_ASSERT(!NS_IsMainThread());
 
-  // Clean up watchers, statuses, fds
-  mReadWatcher.StopWatchingFileDescriptor();
-  mWriteWatcher.StopWatchingFileDescriptor();
-  mConnectionStatus = SOCKET_DISCONNECTED;
-  mFd.reset(-1);
-
-  // Tell the main thread we've errored
-  nsRefPtr<OnSocketEventTask> t =
-    new OnSocketEventTask(this, OnSocketEventTask::CONNECT_ERROR);
-  NS_DispatchToMainThread(t);
-}
-
-void
-UnixSocketImpl::Accept()
-{
-  MOZ_ASSERT(!NS_IsMainThread());
-  MOZ_ASSERT(mConnector);
+  if (!mConnector) {
+    NS_WARNING("No connector object available!");
+    return;
+  }
 
   // This will set things we don't particularly care about, but it will hand
   // back the correct structure size which is what we do care about.
   if (!mConnector->CreateAddr(true, mAddrSize, mAddr, nullptr)) {
     NS_WARNING("Cannot create socket address!");
-    FireSocketError();
     return;
   }
 
   if (mFd.get() < 0) {
     mFd = mConnector->Create();
     if (mFd.get() < 0) {
-      NS_WARNING("Cannot create socket fd!");
-      FireSocketError();
       return;
     }
 
     if (!SetSocketFlags()) {
-      NS_WARNING("Cannot set socket flags!");
-      FireSocketError();
       return;
     }
 
     if (bind(mFd.get(), (struct sockaddr*)&mAddr, mAddrSize)) {
 #ifdef DEBUG
       CHROMIUM_LOG("...bind(%d) gave errno %d", mFd.get(), errno);
 #endif
-      FireSocketError();
       return;
     }
 
     if (listen(mFd.get(), 1)) {
 #ifdef DEBUG
       CHROMIUM_LOG("...listen(%d) gave errno %d", mFd.get(), errno);
 #endif
-      FireSocketError();
       return;
     }
 
     if (!mConnector->SetUpListenSocket(mFd)) {
       NS_WARNING("Could not set up listen socket!");
-      FireSocketError();
+      nsRefPtr<OnSocketEventTask> t =
+        new OnSocketEventTask(this, OnSocketEventTask::CONNECT_ERROR);
+      NS_DispatchToMainThread(t);
+      mConnectionStatus = SOCKET_DISCONNECTED;
       return;
     }
 
   }
 
   SetUpIO();
 }
 
 void
 UnixSocketImpl::Connect()
 {
   MOZ_ASSERT(!NS_IsMainThread());
-  MOZ_ASSERT(mConnector);
+
+  if (!mConnector) {
+    NS_WARNING("No connector object available!");
+    return;
+  }
 
   if (mFd.get() < 0) {
     mFd = mConnector->Create();
     if (mFd.get() < 0) {
-      NS_WARNING("Cannot create socket fd!");
-      FireSocketError();
       return;
     }
   }
 
   int ret;
 
   if (!mConnector->CreateAddr(false, mAddrSize, mAddr, mAddress.get())) {
     NS_WARNING("Cannot create socket address!");
-    FireSocketError();
     return;
   }
 
   // Select non-blocking IO.
   if (-1 == fcntl(mFd.get(), F_SETFL, O_NONBLOCK)) {
-    NS_WARNING("Cannot set nonblock!");
-    FireSocketError();
+    nsRefPtr<OnSocketEventTask> t =
+      new OnSocketEventTask(this, OnSocketEventTask::CONNECT_ERROR);
+    NS_DispatchToMainThread(t);
+    mConnectionStatus = SOCKET_DISCONNECTED;
     return;
   }
 
   ret = connect(mFd.get(), (struct sockaddr*)&mAddr, mAddrSize);
 
   if (ret) {
     if (errno == EINPROGRESS) {
       // Select blocking IO again, since we've now at least queue'd the connect
       // as nonblock.
       int current_opts = fcntl(mFd.get(), F_GETFL, 0);
       if (-1 == current_opts) {
         NS_WARNING("Cannot get socket opts!");
-        FireSocketError();
+        mFd.reset(-1);
+        nsRefPtr<OnSocketEventTask> t =
+          new OnSocketEventTask(this, OnSocketEventTask::CONNECT_ERROR);
+        NS_DispatchToMainThread(t);
+        mConnectionStatus = SOCKET_DISCONNECTED;
         return;
       }
       if (-1 == fcntl(mFd.get(), F_SETFL, current_opts & ~O_NONBLOCK)) {
         NS_WARNING("Cannot set socket opts to blocking!");
-        FireSocketError();
+        mFd.reset(-1);
+        nsRefPtr<OnSocketEventTask> t =
+          new OnSocketEventTask(this, OnSocketEventTask::CONNECT_ERROR);
+        NS_DispatchToMainThread(t);
+        mConnectionStatus = SOCKET_DISCONNECTED;
         return;
       }
 
       // Set up a write watch to make sure we receive the connect signal
       MessageLoopForIO::current()->WatchFileDescriptor(
         mFd.get(),
         false,
         MessageLoopForIO::WATCH_WRITE,
@@ -620,29 +611,30 @@ UnixSocketImpl::Connect()
 #ifdef DEBUG
       CHROMIUM_LOG("UnixSocket Connection delayed!");
 #endif
       return;
     }
 #if DEBUG
     CHROMIUM_LOG("Socket connect errno=%d\n", errno);
 #endif
-    FireSocketError();
+    mFd.reset(-1);
+    nsRefPtr<OnSocketEventTask> t =
+      new OnSocketEventTask(this, OnSocketEventTask::CONNECT_ERROR);
+    NS_DispatchToMainThread(t);
+    mConnectionStatus = SOCKET_DISCONNECTED;
     return;
   }
 
   if (!SetSocketFlags()) {
-    NS_WARNING("Cannot set socket flags!");
-    FireSocketError();
     return;
   }
 
   if (!mConnector->SetUp(mFd)) {
     NS_WARNING("Could not set up socket!");
-    FireSocketError();
     return;
   }
 
   nsRefPtr<OnSocketEventTask> t =
     new OnSocketEventTask(this, OnSocketEventTask::CONNECT_SUCCESS);
   NS_DispatchToMainThread(t);
   mConnectionStatus = SOCKET_CONNECTED;
 
@@ -865,29 +857,40 @@ UnixSocketImpl::OnFileCanWriteWithoutBlo
     }
   } else if (mConnectionStatus == SOCKET_CONNECTING) {
     int error, ret;
     socklen_t len = sizeof(error);
     ret = getsockopt(mFd.get(), SOL_SOCKET, SO_ERROR, &error, &len);
 
     if (ret || error) {
       NS_WARNING("getsockopt failure on async socket connect!");
-      FireSocketError();
+      mFd.reset(-1);
+      nsRefPtr<OnSocketEventTask> t =
+        new OnSocketEventTask(this, OnSocketEventTask::CONNECT_ERROR);
+      NS_DispatchToMainThread(t);
+      mConnectionStatus = SOCKET_DISCONNECTED;
       return;
     }
 
     if (!SetSocketFlags()) {
-      NS_WARNING("Cannot set socket flags!");
-      FireSocketError();
+      mFd.reset(-1);
+      nsRefPtr<OnSocketEventTask> t =
+        new OnSocketEventTask(this, OnSocketEventTask::CONNECT_ERROR);
+      NS_DispatchToMainThread(t);
+      mConnectionStatus = SOCKET_DISCONNECTED;
       return;
     }
 
     if (!mConnector->SetUp(mFd)) {
       NS_WARNING("Could not set up socket!");
-      FireSocketError();
+      mFd.reset(-1);
+      nsRefPtr<OnSocketEventTask> t =
+        new OnSocketEventTask(this, OnSocketEventTask::CONNECT_ERROR);
+      NS_DispatchToMainThread(t);
+      mConnectionStatus = SOCKET_DISCONNECTED;
       return;
     }
 
     nsRefPtr<OnSocketEventTask> t =
       new OnSocketEventTask(this, OnSocketEventTask::CONNECT_SUCCESS);
     NS_DispatchToMainThread(t);
     mConnectionStatus = SOCKET_CONNECTED;