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

Method handleEvent

src/tscpp/api/InterceptPlugin.cc:278–329  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

276}
277
278void
279InterceptPlugin::handleEvent(int abstract_event, void *edata)
280{
281 TSEvent event = static_cast<TSEvent>(abstract_event);
282 LOG_DEBUG("Received event %d", event);
283
284 switch (event) {
285 case TS_EVENT_NET_ACCEPT:
286 LOG_DEBUG("Handling net accept");
287 state_->net_vc_ = static_cast<TSVConn>(edata);
288 state_->input_.buffer_ = TSIOBufferCreate();
289 state_->input_.reader_ = TSIOBufferReaderAlloc(state_->input_.buffer_);
290 state_->input_.vio_ = TSVConnRead(state_->net_vc_, state_->cont_, state_->input_.buffer_,
291 INT64_MAX /* number of bytes to read - high value initially */);
292
293 state_->hdr_buf_ = TSMBufferCreate();
294 state_->hdr_loc_ = TSHttpHdrCreate(state_->hdr_buf_);
295 state_->request_headers_.reset(state_->hdr_buf_, state_->hdr_loc_);
296 TSHttpHdrTypeSet(state_->hdr_buf_, state_->hdr_loc_, TS_HTTP_TYPE_REQUEST);
297 break;
298
299 case TS_EVENT_VCONN_WRITE_READY: // nothing to do
300 LOG_DEBUG("Got write ready");
301 break;
302
303 case TS_EVENT_VCONN_READ_READY:
304 LOG_DEBUG("Handling read ready");
305 if (doRead()) {
306 break;
307 }
308 // else fall through into the next shut down cases
309 LOG_ERROR("Error while reading request!");
310 // fallthrough
311
312 case TS_EVENT_VCONN_READ_COMPLETE: // fall throughs intentional
313 case TS_EVENT_VCONN_WRITE_COMPLETE:
314 case TS_EVENT_VCONN_EOS:
315 case TS_EVENT_ERROR: // erroring out, nothing more to do
316 case TS_EVENT_NET_ACCEPT_FAILED: // somebody canceled the transaction
317 if (event == TS_EVENT_ERROR) {
318 LOG_ERROR("Unknown Error!");
319 } else if (event == TS_EVENT_NET_ACCEPT_FAILED) {
320 LOG_ERROR("Got net_accept_failed!");
321 }
322 LOG_DEBUG("Shutting down intercept");
323 destroyCont(state_);
324 break;
325
326 default:
327 LOG_ERROR("Unknown event %d", event);
328 }
329}
330
331namespace
332{

Callers 15

process_write_sideMethod · 0.45
process_read_sideMethod · 0.45
process_timeoutMethod · 0.45
connect_reMethod · 0.45
state_send_acceptMethod · 0.45
InvokePluginMethod · 0.45
InvokePluginExtMethod · 0.45
handle_eventMethod · 0.45
transform_to_rangeMethod · 0.45

Calls 8

TSIOBufferCreateFunction · 0.85
TSIOBufferReaderAllocFunction · 0.85
TSVConnReadFunction · 0.85
TSMBufferCreateFunction · 0.85
TSHttpHdrCreateFunction · 0.85
TSHttpHdrTypeSetFunction · 0.85
destroyContFunction · 0.85
resetMethod · 0.45

Tested by

no test coverage detected