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

Method consumer_handler

src/proxy/http/HttpTunnel.cc:1504–1597  ·  view source on GitHub ↗

bool HttpTunnel::consumer_handler(int event, HttpTunnelConsumer* p) Handles events from consumers. If the event is interesting only to the tunnel, this handler takes all necessary actions and returns false If the event is interesting to the state_machine, it calls back the state machine and returns true

Source from the content-addressed store, hash-verified

1502//
1503//
1504bool
1505HttpTunnel::consumer_handler(int event, HttpTunnelConsumer *c)
1506{
1507 bool sm_callback = false;
1508 HttpConsumerHandler jump_point;
1509 HttpTunnelProducer *p = c->producer;
1510
1511 Dbg(dbg_ctl_http_tunnel, "[%" PRId64 "] consumer_handler [%s %s]", sm->sm_id, c->name, HttpDebugNames::get_event_name(event));
1512
1513 ink_assert(c->alive == true);
1514
1515 switch (event) {
1516 case VC_EVENT_WRITE_READY:
1517 this->consumer_reenable(c);
1518 // Once we get a write ready from the origin, we can assume the connect to some degree succeeded
1519 if (c->vc_type == HT_HTTP_SERVER) {
1520 sm->t_state.current.server->clear_connect_fail();
1521 }
1522 break;
1523
1524 case VC_EVENT_WRITE_COMPLETE:
1525 case VC_EVENT_EOS:
1526 case VC_EVENT_ERROR:
1527 case VC_EVENT_ACTIVE_TIMEOUT:
1528 case VC_EVENT_INACTIVITY_TIMEOUT:
1529 ink_assert(c->alive);
1530 ink_assert(c->buffer_reader);
1531 if (c->write_vio) {
1532 c->write_vio->reenable();
1533 }
1534 c->alive = false;
1535
1536 c->bytes_written = c->write_vio ? c->write_vio->ndone : 0;
1537
1538 // Interesting tunnel event, call SM
1539 jump_point = c->vc_handler;
1540 (sm->*jump_point)(event, c);
1541 // Make sure the handler_state is set
1542 // Necessary for post tunnel end processing
1543 if (c->producer && c->producer->handler_state == 0) {
1544 if (event == VC_EVENT_WRITE_COMPLETE) {
1545 c->producer->handler_state = HTTP_SM_POST_SUCCESS;
1546 // If the consumer completed, presumably the producer successfully read
1547 c->producer->read_success = true;
1548 // Go ahead and clean up the producer side
1549 if (p->alive) {
1550 producer_handler(VC_EVENT_READ_COMPLETE, p);
1551 }
1552 } else if (c->vc_type == HT_HTTP_SERVER) {
1553 c->producer->handler_state = HTTP_SM_POST_UA_FAIL;
1554 } else if (c->vc_type == HT_HTTP_CLIENT) {
1555 c->producer->handler_state = HTTP_SM_POST_SERVER_FAIL;
1556 }
1557 }
1558 sm_callback = true;
1559
1560 // Deallocate the reader after calling back the sm
1561 // because buffer problems are easier to debug

Callers

nothing calls this directly

Calls 5

consumer_reenableMethod · 0.95
clear_connect_failMethod · 0.80
dealloc_readerMethod · 0.80
reenableMethod · 0.45
is_throttledMethod · 0.45

Tested by

no test coverage detected