MCPcopy Create free account
hub / github.com/apache/trafficserver / state_read_connection_preface

Method state_read_connection_preface

src/proxy/http2/Http2CommonSession.cc:192–240  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

190}
191
192int
193Http2CommonSession::state_read_connection_preface(int event, void *edata)
194{
195 VIO *vio = static_cast<VIO *>(edata);
196
197 STATE_ENTER(&Http2CommonSession::state_read_connection_preface, event);
198 ink_assert(event == VC_EVENT_READ_COMPLETE || event == VC_EVENT_READ_READY);
199
200 if (this->_read_buffer_reader->read_avail() >= static_cast<int64_t>(HTTP2_CONNECTION_PREFACE_LEN)) {
201 char buf[HTTP2_CONNECTION_PREFACE_LEN];
202 unsigned nbytes;
203
204 nbytes = copy_from_buffer_reader(buf, this->_read_buffer_reader, sizeof(buf));
205 ink_release_assert(nbytes == HTTP2_CONNECTION_PREFACE_LEN);
206
207 if (memcmp(HTTP2_CONNECTION_PREFACE, buf, nbytes) != 0) {
208 Http2SsnDebug("invalid connection preface");
209 this->get_proxy_session()->do_io_close();
210 return 0;
211 }
212
213 // Check whether data is read from early data
214 if (this->read_from_early_data > 0) {
215 this->read_from_early_data -= this->read_from_early_data > nbytes ? nbytes : this->read_from_early_data;
216 }
217
218 Http2SsnDebug("received connection preface");
219 this->_read_buffer_reader->consume(nbytes);
220 HTTP2_SET_SESSION_HANDLER(&Http2CommonSession::state_start_frame_read);
221
222 this->get_netvc()->set_inactivity_timeout(HRTIME_SECONDS(Http2::no_activity_timeout_in));
223 this->get_netvc()->set_active_timeout(HRTIME_SECONDS(Http2::active_timeout_in));
224
225 // XXX start the write VIO ...
226
227 // If we have unconsumed data, start tranferring frames now.
228 if (this->_read_buffer_reader->is_read_avail_more_than(0)) {
229 return this->get_proxy_session()->handleEvent(VC_EVENT_READ_READY, vio);
230 }
231 }
232
233 // XXX We don't have enough data to check the connection preface. We should
234 // reset the accept inactivity
235 // timeout. We should have a maximum timeout to get the session started
236 // though.
237
238 vio->reenable();
239 return 0;
240}
241
242int
243Http2CommonSession::state_start_frame_read(int event, void *edata)

Callers

nothing calls this directly

Calls 12

get_netvcMethod · 0.95
copy_from_buffer_readerFunction · 0.85
memcmpFunction · 0.50
read_availMethod · 0.45
do_io_closeMethod · 0.45
get_proxy_sessionMethod · 0.45
consumeMethod · 0.45
set_active_timeoutMethod · 0.45
handleEventMethod · 0.45
reenableMethod · 0.45

Tested by

no test coverage detected