• Main Page
  • Related Pages
  • Namespaces
  • Data Structures
  • Files
  • File List
  • Globals

Http2SessionAccept.cc

Go to the documentation of this file.
00001 /** @file
00002 
00003   A brief file description
00004 
00005   @section license License
00006 
00007   Licensed to the Apache Software Foundation (ASF) under one
00008   or more contributor license agreements.  See the NOTICE file
00009   distributed with this work for additional information
00010   regarding copyright ownership.  The ASF licenses this file
00011   to you under the Apache License, Version 2.0 (the
00012   "License"); you may not use this file except in compliance
00013   with the License.  You may obtain a copy of the License at
00014 
00015       http://www.apache.org/licenses/LICENSE-2.0
00016 
00017   Unless required by applicable law or agreed to in writing, software
00018   distributed under the License is distributed on an "AS IS" BASIS,
00019   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00020   See the License for the specific language governing permissions and
00021   limitations under the License.
00022  */
00023 
00024 #include "Http2SessionAccept.h"
00025 #include "Http2ClientSession.h"
00026 #include "I_Machine.h"
00027 #include "Error.h"
00028 
00029 Http2SessionAccept::Http2SessionAccept(const HttpSessionAccept::Options& _o)
00030   : SessionAccept(NULL), options(_o)
00031 {
00032   SET_HANDLER(&Http2SessionAccept::mainEvent);
00033 }
00034 
00035 Http2SessionAccept::~Http2SessionAccept()
00036 {
00037 }
00038 
00039 void
00040 Http2SessionAccept::accept(NetVConnection * netvc, MIOBuffer * iobuf, IOBufferReader * reader)
00041 {
00042   // XXX we need to refactor the ACL checks from HttpSessionAccept so that we can invoke them here, and also in
00043   // the SPDY protocol layer ...
00044   Warning("skipping access control checks for HTTP/2 connection");
00045 
00046   netvc->attributes = this->options.transport_type;
00047 
00048   if (is_debug_tag_set("http2_seq")) {
00049     const sockaddr * client_ip = netvc->get_remote_addr();
00050     ip_port_text_buffer ipb;
00051 
00052     Debug("http2_seq", "[HttpSessionAccept2:mainEvent %p] accepted connection from %s transport type = %d",
00053       netvc, ats_ip_nptop(client_ip, ipb, sizeof(ipb)), netvc->attributes);
00054   }
00055 
00056   // XXX Allocate a Http2ClientSession
00057   Http2ClientSession * new_session = http2ClientSessionAllocator.alloc();
00058 
00059   new_session->new_connection(netvc, iobuf, reader, false /* backdoor */);
00060 }
00061 
00062 int
00063 Http2SessionAccept::mainEvent(int event, void *data)
00064 {
00065   ink_release_assert(event == NET_EVENT_ACCEPT || event == EVENT_ERROR);
00066   ink_release_assert((event == NET_EVENT_ACCEPT) ? (data != 0) : (1));
00067 
00068   if (event == NET_EVENT_ACCEPT) {
00069     this->accept(static_cast<NetVConnection *>(data), NULL, NULL);
00070     return EVENT_CONT;
00071   }
00072 
00073   // XXX We should hoist the error handling so that all the protocols generate the statistics
00074   // without code duplication.
00075   if (((long) data) == -ECONNABORTED) {
00076     HTTP_SUM_DYN_STAT(http_ua_msecs_counts_errors_pre_accept_hangups_stat, 0);
00077   }
00078 
00079   MachineFatal("HTTP/2 accept received fatal error: errno = %d", -((int)(intptr_t)data));
00080   return EVENT_CONT;
00081 }

Generated by  doxygen 1.7.1