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

Method tunnel_handler_cache_write

src/proxy/http/HttpSM.cc:3745–3798  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3743}
3744
3745int
3746HttpSM::tunnel_handler_cache_write(int event, HttpTunnelConsumer *c)
3747{
3748 STATE_ENTER(&HttpSM::tunnel_handler_cache_write, event);
3749 SMDbg(dbg_ctl_http, "handling cache event: %s", HttpDebugNames::get_event_name(event));
3750
3751 HttpTransact::CacheWriteStatus_t *status_ptr =
3752 (c->producer->vc_type == HT_TRANSFORM) ? &t_state.cache_info.transform_write_status : &t_state.cache_info.write_status;
3753
3754 switch (event) {
3755 case VC_EVENT_ERROR:
3756 case VC_EVENT_EOS:
3757 // Abnormal termination
3758 *status_ptr = HttpTransact::CACHE_WRITE_ERROR;
3759 c->write_vio = nullptr;
3760 c->vc->do_io_close(EHTTP_ERROR);
3761
3762 Metrics::Counter::increment(http_rsb.cache_write_errors);
3763 SMDbg(dbg_ctl_http, "aborting cache write due %s event from cache", HttpDebugNames::get_event_name(event));
3764 // abort the producer if the cache_writevc is the only consumer.
3765 if (c->producer->alive && c->producer->num_consumers == 1) {
3766 tunnel.chain_abort_all(c->producer);
3767 }
3768 break;
3769 case VC_EVENT_WRITE_COMPLETE:
3770 // if we've never initiated a cache write
3771 // abort the cache since it's finicky about a close
3772 // in this case. This case can only occur
3773 // we got a truncated header from the origin server
3774 // but decided to accept it anyways
3775 if (c->write_vio == nullptr) {
3776 *status_ptr = HttpTransact::CACHE_WRITE_ERROR;
3777 c->write_success = false;
3778 c->vc->do_io_close(EHTTP_ERROR);
3779 } else {
3780 *status_ptr = HttpTransact::CACHE_WRITE_COMPLETE;
3781 c->write_success = true;
3782 c->vc->do_io_close();
3783 c->write_vio = nullptr;
3784 }
3785 break;
3786 default:
3787 // All other events indicate problems
3788 ink_assert(0);
3789 break;
3790 }
3791
3792 if (background_fill != BACKGROUND_FILL_NONE) {
3793 server_response_body_bytes = c->bytes_written;
3794 }
3795
3796 Metrics::Gauge::decrement(http_rsb.current_cache_connections);
3797 return 0;
3798}
3799
3800int
3801HttpSM::tunnel_handler_post_ua(int event, HttpTunnelProducer *p)

Callers

nothing calls this directly

Calls 3

incrementFunction · 0.85
chain_abort_allMethod · 0.80
do_io_closeMethod · 0.45

Tested by

no test coverage detected