shinrich commented on a change in pull request #7622:
URL: https://github.com/apache/trafficserver/pull/7622#discussion_r647638615



##########
File path: proxy/http/HttpSM.cc
##########
@@ -1801,19 +1945,51 @@ HttpSM::handle_api_return()
 }
 
 PoolableSession *
-HttpSM::create_server_session(NetVConnection *netvc)
+HttpSM::create_server_session(NetVConnection *netvc, MIOBuffer 
*netvc_read_buffer, IOBufferReader *netvc_reader)
 {
   HttpTransact::State &s  = this->t_state;
-  PoolableSession *retval = httpServerSessionAllocator.alloc();
+  PoolableSession *retval = nullptr;
+
+  // Figure out what protocol was negotiated
+  const unsigned char *proto  = nullptr;
+  unsigned int proto_length   = 0;
+  SSLNetVConnection *sslnetvc = dynamic_cast<SSLNetVConnection *>(netvc);
+  if (sslnetvc) {
+    SSL_get0_alpn_selected(sslnetvc->ssl, &proto, &proto_length);
+  }
 
-  retval->sharing_pool         = 
static_cast<TSServerSessionSharingPoolType>(s.http_config_param->server_session_sharing_pool);
-  retval->sharing_match        = 
static_cast<TSServerSessionSharingMatchMask>(s.txn_conf->server_session_sharing_match);
-  MIOBuffer *netvc_read_buffer = 
new_MIOBuffer(HTTP_SERVER_RESP_HDR_BUFFER_INDEX);
-  IOBufferReader *netvc_reader = netvc_read_buffer->alloc_reader();
+  bool add_session = false;
+  if (proto_length == 2 && memcmp(proto, "h2", 2) == 0) {
+    Http2ServerSession *session = http2ServerSessionAllocator.alloc();
+    add_session                 = true;
+    retval                      = session;
+  } else {
+    Http1ServerSession *session = httpServerSessionAllocator.alloc();
+    retval                      = session;
+  }

Review comment:
       pulled out into a static method.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to