maskit commented on code in PR #8963:
URL: https://github.com/apache/trafficserver/pull/8963#discussion_r921925481


##########
proxy/http2/Http2ServerSession.cc:
##########
@@ -0,0 +1,420 @@
+/** @file
+
+  Http2ServerSession.
+
+  @section license License
+
+  Licensed to the Apache Software Foundation (ASF) under one
+  or more contributor license agreements.  See the NOTICE file
+  distributed with this work for additional information
+  regarding copyright ownership.  The ASF licenses this file
+  to you under the Apache License, Version 2.0 (the
+  "License"); you may not use this file except in compliance
+  with the License.  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+ */
+
+#include "Http2ServerSession.h"
+#include "HttpDebugNames.h"
+#include "tscore/ink_base64.h"
+#include "Http2CommonSessionInternal.h"
+#include "HttpSessionManager.h"
+#include "P_SSLNetVConnection.h"
+
+ClassAllocator<Http2ServerSession> 
http2ServerSessionAllocator("http2ServerSessionAllocator");
+
+static int
+send_connection_event(Continuation *cont, int event, void *edata)
+{
+  SCOPED_MUTEX_LOCK(lock, cont->mutex, this_ethread());
+  return cont->handleEvent(event, edata);
+}
+
+Http2ServerSession::Http2ServerSession() = default;
+
+void
+Http2ServerSession::destroy()
+{
+  if (!in_destroy) {
+    in_destroy = true;
+    write_vio  = nullptr;
+    this->remove_session();
+    this->release_outbound_connection_tracking();
+    REMEMBER(NO_EVENT, this->recursion)
+    Http2SsnDebug("session destroy");
+    if (_vc) {
+      _vc->do_io_close();
+      _vc = nullptr;
+    }
+    free();
+  }
+}
+
+void
+Http2ServerSession::free()
+{
+  auto mutex_thread = this->mutex->thread_holding;
+  if (Http2CommonSession::common_free(this)) {
+    HTTP2_DECREMENT_THREAD_DYN_STAT(HTTP2_STAT_CURRENT_SERVER_SESSION_COUNT, 
mutex_thread);
+    THREAD_FREE(this, http2ServerSessionAllocator, mutex_thread);
+  }
+}
+
+void
+Http2ServerSession::start()
+{
+  SCOPED_MUTEX_LOCK(lock, this->mutex, this_ethread());
+
+  SET_HANDLER(&Http2ServerSession::main_event_handler);
+  HTTP2_SET_SESSION_HANDLER(&Http2ServerSession::state_start_frame_read);
+
+  VIO *read_vio = this->do_io_read(this, INT64_MAX, this->read_buffer);
+  write_vio     = this->do_io_write(this, INT64_MAX, 
this->_write_buffer_reader);
+
+  this->connection_state.init(this);
+
+  // 3.5 HTTP/2 Connection Preface. Upon establishment of a TCP connection and
+  // determination that HTTP/2 will be used by both peers, each endpoint MUST
+  // send a connection preface as a final confirmation ...
+  // This is the preface string sent by the client
+  this->write_buffer->write(HTTP2_CONNECTION_PREFACE, 
HTTP2_CONNECTION_PREFACE_LEN);
+  total_write_len += HTTP2_CONNECTION_PREFACE_LEN;
+  // write_vio->nbytes = total_write_len;
+  write_reenable();
+  this->connection_state.send_connection_preface();
+  Http2SsnDebug("Sent Connection Preface");
+
+  this->handleEvent(VC_EVENT_READ_READY, read_vio);
+}
+
+void
+Http2ServerSession::new_connection(NetVConnection *new_vc, MIOBuffer *iobuf, 
IOBufferReader *reader)
+{
+  ink_assert(new_vc->mutex->thread_holding == this_ethread());
+  HTTP2_INCREMENT_THREAD_DYN_STAT(HTTP2_STAT_CURRENT_SERVER_SESSION_COUNT, 
new_vc->mutex->thread_holding);
+  HTTP2_INCREMENT_THREAD_DYN_STAT(HTTP2_STAT_TOTAL_SERVER_CONNECTION_COUNT, 
new_vc->mutex->thread_holding);
+  this->_milestones.mark(Http2SsnMilestone::OPEN);
+
+  // Unique client session identifier.
+  this->con_id = ProxySession::next_connection_id();
+  this->_vc    = new_vc;
+  
_vc->set_inactivity_timeout(HRTIME_SECONDS(Http2::accept_no_activity_timeout));
+  this->schedule_event = nullptr;
+  this->mutex          = new_vc->mutex;
+
+  this->connection_state.mutex = this->mutex;
+
+  TLSEarlyDataSupport *eds = dynamic_cast<TLSEarlyDataSupport *>(new_vc);
+  if (eds != nullptr) {
+    this->read_from_early_data = eds->get_early_data_len();

Review Comment:
   A client never receives early data. We don't need this block.



-- 
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.

To unsubscribe, e-mail: [email protected]

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

Reply via email to