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

Method tunnel_handler_transform_write

src/proxy/http/HttpSM.cc:4183–4266  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4181}
4182
4183int
4184HttpSM::tunnel_handler_transform_write(int event, HttpTunnelConsumer *c)
4185{
4186 STATE_ENTER(&HttpSM::tunnel_handler_transform_write, event);
4187
4188 HttpTransformInfo *i;
4189
4190 // Figure out if this the request or response transform
4191 // : use post_transform_info.entry because post_transform_info.vc
4192 // is not set to NULL after the post transform is done.
4193 if (post_transform_info.entry && post_transform_info.entry->vc == c->vc) {
4194 i = &post_transform_info;
4195 } else {
4196 i = &transform_info;
4197 ink_assert(c->vc == i->vc);
4198 ink_assert(c->vc == i->entry->vc);
4199 }
4200
4201 switch (event) {
4202 case VC_EVENT_ERROR:
4203 // Transform error
4204 tunnel.chain_abort_all(c->producer);
4205 c->handler_state = HTTP_SM_TRANSFORM_FAIL;
4206 c->vc->do_io_close(EHTTP_ERROR);
4207 break;
4208 case VC_EVENT_EOS:
4209 // It possible the transform quit
4210 // before the producer finished. If this is true
4211 // we need shut down the producer if it doesn't
4212 // have other consumers to serve or else it will
4213 // fill up buffer and get hung
4214 if (c->producer->alive && c->producer->num_consumers == 1) {
4215 // Send a tunnel detach event to the producer
4216 // to shut it down but indicates it should not abort
4217 // downstream (on the other side of the transform)
4218 // cache writes
4219 tunnel.producer_handler(HTTP_TUNNEL_EVENT_CONSUMER_DETACH, c->producer);
4220 }
4221 // FALLTHROUGH
4222 case VC_EVENT_WRITE_COMPLETE:
4223 // write to transform complete - shutdown the write side
4224 c->write_success = true;
4225 c->vc->do_io_shutdown(IO_SHUTDOWN_WRITE);
4226
4227 // If the read side has not started up yet, then the
4228 // this transform_vc is no longer owned by the tunnel
4229 if (c->self_producer == nullptr) {
4230 i->entry->in_tunnel = false;
4231 } else if (c->self_producer->alive == false) {
4232 // The read side of the Transform
4233 // has already completed (possible when the
4234 // transform intentionally truncates the response).
4235 // So close it
4236 c->vc->do_io_close();
4237 }
4238 break;
4239 default:
4240 ink_release_assert(0);

Callers

nothing calls this directly

Calls 4

chain_abort_allMethod · 0.80
producer_handlerMethod · 0.80
do_io_closeMethod · 0.45
do_io_shutdownMethod · 0.45

Tested by

no test coverage detected