Bug 1337791 - JoinConnection() from psm 1/3 r=keeler draft
authorPatrick McManus <mcmanus@ducksong.com>
Mon, 03 Apr 2017 17:23:09 -0400
changeset 555239 0078ede4db4f9b681e9c080dfb7b3c410f58db1d
parent 555238 2f38397908ce1699258b0689393011af50c15438
child 555240 d3605a438c7397726c100b26db082adb87eeac10
push id52202
push userbmo:mcmanus@ducksong.com
push dateMon, 03 Apr 2017 21:42:06 +0000
reviewerskeeler
bugs1337791
milestone55.0a1
Bug 1337791 - JoinConnection() from psm 1/3 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;
 }