Bug 1337791 - Part 1: JoinConnection() from psm. r=keeler
authorPatrick McManus <mcmanus@ducksong.com>
Mon, 03 Apr 2017 17:23:09 -0400
changeset 351182 7f8f5cada5b7e2ae6f26ef4a2eecee3f6b33767d
parent 351181 23674d7089036e3c7cb8333b3eaec3b805996d72
child 351183 fbb9934d1a90a696f659b71c08886895b2edbbdd
push id88808
push userryanvm@gmail.com
push dateTue, 04 Apr 2017 18:42:26 +0000
treeherdermozilla-inbound@71b228f12fc1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskeeler
bugs1337791
milestone55.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 1337791 - Part 1: JoinConnection() from psm. r=keeler
netwerk/socket/nsISSLSocketControl.idl
security/manager/ssl/nsNSSIOLayer.cpp
--- a/netwerk/socket/nsISSLSocketControl.idl
+++ b/netwerk/socket/nsISSLSocketControl.idl
@@ -57,20 +57,28 @@ interface nsISSLSocketControl : nsISuppo
 
     /* When 0RTT is performed, PR_Write will not drive the handshake forward.
      * It must be forced by calling this function.
      */
     void driveHandshake();
 
     /* Determine if a potential SSL connection to hostname:port with
      * a desired NPN negotiated protocol of npnProtocol can use the socket
-     * associated with this object instead of making a new one.
+     * associated with this object instead of making a new one. And if so, combine
+     * them.
      */
     boolean joinConnection(
-      in ACString npnProtocol, /* e.g. "spdy/2" */
+      in ACString npnProtocol, /* e.g. "h2" */
+      in ACString hostname,
+      in long port);
+
+    /* just like JoinConnection() except do not mark a successful test as joined.
+     */
+    boolean testJoinConnection(
+      in ACString npnProtocol, /* e.g. "h2" */
       in ACString hostname,
       in long port);
 
     /* Determine if existing connection should be trusted to convey information about
      * a hostname.
      */
     boolean isAcceptableForHost(in ACString hostname);
 
--- a/security/manager/ssl/nsNSSIOLayer.cpp
+++ b/security/manager/ssl/nsNSSIOLayer.cpp
@@ -468,20 +468,20 @@ nsNSSSocketInfo::IsAcceptableForHost(con
   }
 
   // All tests pass
   *_retval = true;
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsNSSSocketInfo::JoinConnection(const nsACString& npnProtocol,
-                                const nsACString& hostname,
-                                int32_t port,
-                                bool* _retval)
+nsNSSSocketInfo::TestJoinConnection(const nsACString& npnProtocol,
+                                    const nsACString& hostname,
+                                    int32_t port,
+                                    bool* _retval)
 {
   *_retval = false;
 
   // Different ports may not be joined together
   if (port != GetPort())
     return NS_OK;
 
   // Make sure NPN has been completed and matches requested npnProtocol
@@ -489,23 +489,32 @@ nsNSSSocketInfo::JoinConnection(const ns
     return NS_OK;
 
   if (mBypassAuthentication) {
     // An unauthenticated connection does not know whether or not it
     // is acceptable for a particular hostname
     return NS_OK;
   }
 
-  IsAcceptableForHost(hostname, _retval);
-
-  if (*_retval) {
+  IsAcceptableForHost(hostname, _retval); // sets _retval
+  return NS_OK;
+}
+
+NS_IMETHODIMP
+nsNSSSocketInfo::JoinConnection(const nsACString& npnProtocol,
+                                const nsACString& hostname,
+                                int32_t port,
+                                bool* _retval)
+{
+  nsresult rv = TestJoinConnection(npnProtocol, hostname, port, _retval);
+  if (NS_SUCCEEDED(rv) && *_retval) {
     // All tests pass - this is joinable
     mJoined = true;
   }
-  return NS_OK;
+  return rv;
 }
 
 bool
 nsNSSSocketInfo::GetForSTARTTLS()
 {
   return mForSTARTTLS;
 }