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

Method do_io_close

src/proxy/http/Http1ClientSession.cc:225–287  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

223}
224
225void
226Http1ClientSession::do_io_close(int alerrno)
227{
228 if (read_state == HCS_CLOSED) {
229 if (transact_count == released_transactions) {
230 this->destroy();
231 }
232 return; // Don't double call session close
233 }
234 if (read_state == HCS_ACTIVE_READER) {
235 clear_session_active();
236 }
237
238 // Prevent double closing
239 ink_release_assert(read_state != HCS_CLOSED);
240
241 // If we have an attached server session, release
242 // it back to our shared pool
243 if (bound_ss) {
244 bound_ss->release(nullptr);
245 bound_ss = nullptr;
246 slave_ka_vio = nullptr;
247 }
248 // Completed the last transaction. Just shutdown already
249 // Or the do_io_close is due to a network error
250 if (transact_count == released_transactions || alerrno == HTTP_ERRNO) {
251 half_close = false;
252 }
253
254 if (half_close && this->trans.get_sm()) {
255 read_state = HCS_HALF_CLOSED;
256 SET_HANDLER(&Http1ClientSession::state_wait_for_close);
257 HttpSsnDbg("[%" PRId64 "] session half close", con_id);
258
259 if (_vc) {
260 _vc->do_io_shutdown(IO_SHUTDOWN_WRITE);
261
262 ka_vio = _vc->do_io_read(this, INT64_MAX, read_buffer);
263 ink_assert(slave_ka_vio != ka_vio);
264
265 // Set the active timeout to the same as the inactive time so
266 // that this connection does not hang around forever if
267 // the ua hasn't closed
268 _vc->set_active_timeout(HRTIME_SECONDS(trans.get_sm()->t_state.txn_conf->keep_alive_no_activity_timeout_in));
269 }
270
271 // [bug 2610799] Drain any data read.
272 // If the buffer is full and the client writes again, we will not receive a
273 // READ_READY event.
274 _reader->consume(_reader->read_avail());
275 } else {
276 HttpSsnDbg("[%" PRId64 "] session closed", con_id);
277 read_state = HCS_CLOSED;
278
279 if (_vc) {
280 _vc->do_io_close();
281 _vc = nullptr;
282 }

Callers 5

state_wait_for_closeMethod · 0.95
state_keep_aliveMethod · 0.95
new_transactionMethod · 0.95
freeMethod · 0.45

Calls 8

destroyMethod · 0.95
get_smMethod · 0.80
releaseMethod · 0.45
do_io_shutdownMethod · 0.45
do_io_readMethod · 0.45
set_active_timeoutMethod · 0.45
consumeMethod · 0.45
read_availMethod · 0.45

Tested by

no test coverage detected