Bug 1429106 - Fix TFO telemetry. r=nwgh
authorDragana Damjanovic <dd.mozilla@gmail.com>
Wed, 10 Jan 2018 12:39:55 +0100
changeset 450365 68b7531613497d4278991e7e32fca8378f657534
parent 450364 11c801abda3c68b438668e2d5f267f5c6371e584
child 450366 5241bdbfa0a559c001a9de789c466c9506493490
push id8527
push userCallek@gmail.com
push dateThu, 11 Jan 2018 21:05:50 +0000
treeherdermozilla-beta@95342d212a7a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnwgh
bugs1429106
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 1429106 - Fix TFO telemetry. r=nwgh
netwerk/base/TCPFastOpenLayer.h
netwerk/protocol/http/nsHttpConnectionMgr.cpp
--- a/netwerk/base/TCPFastOpenLayer.h
+++ b/netwerk/base/TCPFastOpenLayer.h
@@ -60,16 +60,17 @@ typedef enum {
   TFO_FAILED_BACKUP_CONNECTION_TFO_DATA_COOKIE_NOT_ACCEPTED,
   // The following 4 are set when the recovery connection fails as well.
   TFO_FAILED_CONNECTION_REFUSED_NO_TFO_FAILED_TOO,
   TFO_FAILED_NET_TIMEOUT_NO_TFO_FAILED_TOO,
   TFO_FAILED_UNKNOW_ERROR_NO_TFO_FAILED_TOO,
   TFO_FAILED_BACKUP_CONNECTION_NO_TFO_FAILED_TOO,
   TFO_BACKUP_CONN, // This is a backup conn, for a halfOpenSock that was used
                    // TFO.
+  TFO_INIT_FAILED, // nsHalfOpenSocket::SetupConn failed.
   TFO_FAILED,
   TFO_HTTP // TFO is disabled for non-secure connections.
 } TFOResult;
 
 nsresult AttachTCPFastOpenIOLayer(PRFileDesc *fd);
 
 // Get the result of TCP Fast Open.
 void TCPFastOpenFinish(PRFileDesc *fd, PRErrorCode &err,
--- a/netwerk/protocol/http/nsHttpConnectionMgr.cpp
+++ b/netwerk/protocol/http/nsHttpConnectionMgr.cpp
@@ -3981,17 +3981,17 @@ nsHalfOpenSocket::SetupStreams(nsISocket
              (isBackup && gHttpHandler->FastFallbackToIPv4())) {
         tmpFlags |= nsISocketTransport::DISABLE_IPV6;
     }
 
     if (!Allow1918()) {
         tmpFlags |= nsISocketTransport::DISABLE_RFC1918;
     }
 
-    if (!isBackup) {
+    if ((mFastOpenStatus != TFO_HTTP) && !isBackup) {
         if (mEnt->mUseFastOpen) {
             socketTransport->SetFastOpenCallback(this);
         } else {
             mFastOpenStatus = TFO_DISABLED;
         }
     }
 
     socketTransport->SetConnectionFlags(tmpFlags);
@@ -4714,16 +4714,23 @@ nsHalfOpenSocket::SetupConn(nsIAsyncOutp
         MOZ_ASSERT(false, "unexpected stream");
         rv = NS_ERROR_UNEXPECTED;
     }
 
     if (NS_FAILED(rv)) {
         LOG(("nsHalfOpenSocket::SetupConn "
              "conn->init (%p) failed %" PRIx32 "\n",
              conn.get(), static_cast<uint32_t>(rv)));
+
+        // Set TFO status.
+        if (mFastOpenStatus == TFO_HTTP) {
+            conn->SetFastOpenStatus(TFO_HTTP);
+        } else {
+            conn->SetFastOpenStatus(TFO_INIT_FAILED);
+        }
         return rv;
     }
 
     // This half-open socket has created a connection.  This flag excludes it
     // from counter of actual connections used for checking limits.
     if (!aFastOpen) {
         mHasConnected = true;
     }
@@ -4817,23 +4824,26 @@ nsHalfOpenSocket::SetupConn(nsIAsyncOutp
     if (aFastOpen) {
         MOZ_ASSERT(mEnt);
         MOZ_ASSERT(static_cast<int32_t>(mEnt->mIdleConns.IndexOf(conn)) == -1);
         int32_t idx = mEnt->mActiveConns.IndexOf(conn);
         if (NS_SUCCEEDED(rv) && (idx != -1)) {
             mConnectionNegotiatingFastOpen = conn;
         } else {
             conn->SetFastOpen(false);
+            conn->SetFastOpenStatus(TFO_INIT_FAILED);
         }
     } else {
         conn->SetFastOpenStatus(mFastOpenStatus);
-        mFastOpenStatus = TFO_BACKUP_CONN; // Set this to TFO_BACKUP_CONN so
-                                           // that if a backup connection is
-                                           // established we do not report
-                                           // values twice.
+        if (mFastOpenStatus != TFO_HTTP) {
+            mFastOpenStatus = TFO_BACKUP_CONN; // Set this to TFO_BACKUP_CONN
+                                               // so that if a backup
+                                               // connection is established we
+                                               // do not report values twice.
+        }
     }
 
     // If this halfOpenConn was speculative, but at the ende the conn got a
     // non-null transaction than this halfOpen is not speculative anymore!
     if (conn->Transaction() && !conn->Transaction()->IsNullTransaction()) {
         Claim();
     }