Bug 1252163: Fix CheckTcpConnectivity to wait for readable/writeable when necessary. r=drno
authorByron Campen [:bwc] <docfaraday@gmail.com>
Mon, 29 Feb 2016 12:33:47 -0600
changeset 322846 8d2dbe77299c386a135b04fdbe8abef2d4e28674
parent 322845 61519a71531e9516ca32f49009bf1f17c2df882d
child 322847 a8b211e48faad67323ee6a2cdcae86019b290d64
push id5913
push userjlund@mozilla.com
push dateMon, 25 Apr 2016 16:57:49 +0000
treeherdermozilla-beta@dcaf0a6fa115 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdrno
bugs1252163
milestone47.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 1252163: Fix CheckTcpConnectivity to wait for readable/writeable when necessary. r=drno MozReview-Commit-ID: 6hz0eCghYE0
media/mtransport/test/test_nr_socket_unittest.cpp
--- a/media/mtransport/test/test_nr_socket_unittest.cpp
+++ b/media/mtransport/test/test_nr_socket_unittest.cpp
@@ -199,51 +199,66 @@ class TestNrSocketTest : public Mtranspo
     NrSocketBase *accepted_sock;
     if (!Connect(from, to, &accepted_sock)) {
       std::cerr << "Connect failed" << std::endl;
       return false;
     }
 
     // write on |from|, recv on |accepted_sock|
     if (!WaitForWriteable(from)) {
-      std::cerr << __LINE__ << "WaitForWriteable failed" << std::endl;
+      std::cerr << __LINE__ << "WaitForWriteable (1) failed" << std::endl;
       return false;
     }
 
     int r;
     sts_->Dispatch(WrapRunnableRet(&r,
                                    this,
                                    &TestNrSocketTest::SendDataTcp_s,
                                    from),
                    NS_DISPATCH_SYNC);
     if (r) {
       std::cerr << "SendDataTcp_s (1) failed" << std::endl;
       return false;
     }
 
+    if (!WaitForReadable(accepted_sock)) {
+      std::cerr << __LINE__ << "WaitForReadable (1) failed" << std::endl;
+      return false;
+    }
+
     sts_->Dispatch(WrapRunnableRet(&r,
                                    this,
                                    &TestNrSocketTest::RecvDataTcp_s,
                                    accepted_sock),
                    NS_DISPATCH_SYNC);
     if (r) {
       std::cerr << "RecvDataTcp_s (1) failed" << std::endl;
       return false;
     }
 
+    if (!WaitForWriteable(accepted_sock)) {
+      std::cerr << __LINE__ << "WaitForWriteable (2) failed" << std::endl;
+      return false;
+    }
+
     sts_->Dispatch(WrapRunnableRet(&r,
                                    this,
                                    &TestNrSocketTest::SendDataTcp_s,
                                    accepted_sock),
                    NS_DISPATCH_SYNC);
     if (r) {
       std::cerr << "SendDataTcp_s (2) failed" << std::endl;
       return false;
     }
 
+    if (!WaitForReadable(from)) {
+      std::cerr << __LINE__ << "WaitForReadable (2) failed" << std::endl;
+      return false;
+    }
+
     sts_->Dispatch(WrapRunnableRet(&r,
                                    this,
                                    &TestNrSocketTest::RecvDataTcp_s,
                                    from),
                    NS_DISPATCH_SYNC);
     if (r) {
       std::cerr << "RecvDataTcp_s (2) failed" << std::endl;
       return false;
@@ -385,17 +400,17 @@ class TestNrSocketTest : public Mtranspo
     if (r) {
       std::cerr << "Accept_s failed: " << r << std::endl;
       return false;
     }
     return true;
   }
 
 
-  bool WaitForSocketState(TestNrSocket *sock, int state) {
+  bool WaitForSocketState(NrSocketBase *sock, int state) {
     MOZ_ASSERT(sock);
     sts_->Dispatch(WrapRunnable(this,
                                 &TestNrSocketTest::WaitForSocketState_s,
                                 sock,
                                 state),
                    NS_DISPATCH_SYNC);
 
     bool res;
@@ -408,29 +423,29 @@ class TestNrSocketTest : public Mtranspo
                                   sock,
                                   state),
                      NS_DISPATCH_SYNC);
     }
 
     return res;
   }
 
-  void WaitForSocketState_s(TestNrSocket *sock, int state) {
+  void WaitForSocketState_s(NrSocketBase *sock, int state) {
      NR_ASYNC_WAIT(sock, state, &WaitDone, this);
   }
 
-  void CancelWait_s(TestNrSocket *sock, int state) {
+  void CancelWait_s(NrSocketBase *sock, int state) {
      sock->cancel(state);
   }
 
-  bool WaitForReadable(TestNrSocket *sock) {
+  bool WaitForReadable(NrSocketBase *sock) {
     return WaitForSocketState(sock, NR_ASYNC_WAIT_READ);
   }
 
-  bool WaitForWriteable(TestNrSocket *sock) {
+  bool WaitForWriteable(NrSocketBase *sock) {
     return WaitForSocketState(sock, NR_ASYNC_WAIT_WRITE);
   }
 
   static void WaitDone(void *sock, int how, void *test_fixture) {
     TestNrSocketTest *test = static_cast<TestNrSocketTest*>(test_fixture);
     test->wait_done_for_main_ = true;
   }