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

Function handle_client_resp

plugins/slice/client.cc:124–182  ·  view source on GitHub ↗

this is when the client starts asking us for more data

Source from the content-addressed store, hash-verified

122
123// this is when the client starts asking us for more data
124void
125handle_client_resp(TSCont contp, TSEvent event, Data *const data)
126{
127 switch (event) {
128 case TS_EVENT_VCONN_WRITE_READY: {
129 switch (data->m_blockstate) {
130 case BlockState::Fail:
131 case BlockState::PendingRef:
132 case BlockState::ActiveRef: {
133 TSVIO const output_vio = data->m_dnstream.m_write.m_vio;
134 int64_t const output_done = TSVIONDoneGet(output_vio);
135 int64_t const output_sent = data->m_bytessent;
136
137 if (output_sent == output_done) {
138 DEBUG_LOG("Downstream output is done, shutting down");
139 shutdown(contp, data);
140 }
141 } break;
142
143 case BlockState::Pending: {
144 // throttle
145 TSVIO const output_vio = data->m_dnstream.m_write.m_vio;
146 int64_t const output_done = TSVIONDoneGet(output_vio);
147 int64_t const output_sent = data->m_bytessent;
148 int64_t const threshout = data->m_config->m_blockbytes;
149 int64_t const buffered = output_sent - output_done;
150
151 if (threshout < buffered) {
152 DEBUG_LOG("%p handle_client_resp: throttling %" PRId64, data, buffered);
153 } else {
154 DEBUG_LOG("Starting next block request");
155 if (!request_block(contp, data)) {
156 data->m_blockstate = BlockState::Fail;
157 return;
158 }
159 }
160 } break;
161 case BlockState::Passthru: {
162 } break;
163 default:
164 break;
165 }
166 } break;
167 case TS_EVENT_VCONN_WRITE_COMPLETE: {
168 if (dbg_ctl.on() && reader_avail_more_than(data->m_upstream.m_read.m_reader, 0)) {
169 int64_t const left = TSIOBufferReaderAvail(data->m_upstream.m_read.m_reader);
170 DEBUG_LOG("%p WRITE_COMPLETE called with %" PRId64 " bytes left", data, left);
171 }
172
173 data->m_dnstream.close();
174 if (!data->m_upstream.m_read.isOpen()) {
175 shutdown(contp, data);
176 }
177 } break;
178 default: {
179 DEBUG_LOG("%p handle_client_resp unhandled event %d %s", data, event, TSHttpEventNameLookup(event));
180 } break;
181 }

Callers 1

intercept_hookFunction · 0.85

Calls 9

TSVIONDoneGetFunction · 0.85
shutdownFunction · 0.85
request_blockFunction · 0.85
reader_avail_more_thanFunction · 0.85
TSIOBufferReaderAvailFunction · 0.85
TSHttpEventNameLookupFunction · 0.85
onMethod · 0.45
closeMethod · 0.45
isOpenMethod · 0.45

Tested by

no test coverage detected