| 84 | } |
| 85 | |
| 86 | Http2Stream::~Http2Stream() |
| 87 | { |
| 88 | REMEMBER(NO_EVENT, this->reentrancy_count); |
| 89 | Http2StreamDebug("Destroy stream, sent %" PRIu64 " bytes, registered: %s", this->bytes_sent, |
| 90 | (_registered_stream ? "true" : "false")); |
| 91 | |
| 92 | // In the case of a temporary stream used to parse the header to keep the HPACK |
| 93 | // up to date, there may not be a mutex. Nothing was set up, so nothing to |
| 94 | // clean up in the destructor |
| 95 | if (this->mutex == nullptr) { |
| 96 | return; |
| 97 | } |
| 98 | |
| 99 | SCOPED_MUTEX_LOCK(lock, this->mutex, this_ethread()); |
| 100 | // Clean up after yourself if this was an EOS |
| 101 | ink_release_assert(this->closed); |
| 102 | ink_release_assert(reentrancy_count == 0); |
| 103 | |
| 104 | uint64_t cid = 0; |
| 105 | |
| 106 | if (_registered_stream) { |
| 107 | // Safe to initiate SSN_CLOSE if this is the last stream |
| 108 | if (_proxy_ssn) { |
| 109 | cid = _proxy_ssn->connection_id(); |
| 110 | |
| 111 | SCOPED_MUTEX_LOCK(lock, _proxy_ssn->mutex, this_ethread()); |
| 112 | Http2ConnectionState &connection_state = this->get_connection_state(); |
| 113 | |
| 114 | // Make sure the stream is removed from the stream list and priority tree |
| 115 | // In many cases, this has been called earlier, so this call is a no-op |
| 116 | connection_state.delete_stream(this); |
| 117 | |
| 118 | connection_state.decrement_peer_stream_count(); |
| 119 | |
| 120 | // Update session's stream counts, so it accurately goes into keep-alive state |
| 121 | connection_state.release_stream(); |
| 122 | |
| 123 | // Do not access `_proxy_ssn` in below. It might be freed by `release_stream`. |
| 124 | } |
| 125 | } // Otherwise, not registered with the connection_state (i.e. a temporary stream used for HPACK header processing) |
| 126 | |
| 127 | // Clean up the write VIO in case of inactivity timeout |
| 128 | this->do_io_write(nullptr, 0, nullptr); |
| 129 | |
| 130 | this->_milestones.mark(Http2StreamMilestone::CLOSE); |
| 131 | |
| 132 | ink_hrtime total_time = this->_milestones.elapsed(Http2StreamMilestone::OPEN, Http2StreamMilestone::CLOSE); |
| 133 | Metrics::Counter::increment(http2_rsb.total_transactions_time, total_time); |
| 134 | |
| 135 | // Slow Log |
| 136 | if (Http2::stream_slow_log_threshold != 0 && ink_hrtime_from_msec(Http2::stream_slow_log_threshold) < total_time) { |
| 137 | Error("[%" PRIu64 "] [%" PRIu32 "] [%" PRId64 "] Slow H2 Stream: " |
| 138 | "open: %" PRIu64 " " |
| 139 | "dec_hdrs: %.3f " |
| 140 | "txn: %.3f " |
| 141 | "enc_hdrs: %.3f " |
| 142 | "tx_hdrs: %.3f " |
| 143 | "tx_data: %.3f " |
nothing calls this directly
no test coverage detected