If resource needs to be destroyed or memory needs to be deleted (both directly and indirectly referenced), do them in this method. Notice that you don't have to set the fields to initial state after deletion since they'll be set uniformly after this method is called.
| 183 | // you don't have to set the fields to initial state after deletion since |
| 184 | // they'll be set uniformly after this method is called. |
| 185 | void Controller::ResetNonPods() { |
| 186 | if (auto span = _span.lock()) { |
| 187 | Span::Submit(span, butil::cpuwide_time_us()); |
| 188 | } |
| 189 | _error_text.clear(); |
| 190 | _remote_side = butil::EndPoint(); |
| 191 | _local_side = butil::EndPoint(); |
| 192 | if (_session_local_data) { |
| 193 | _server->_session_local_data_pool->Return(_session_local_data); |
| 194 | } |
| 195 | _mongo_session_data.reset(); |
| 196 | delete _sampled_request; |
| 197 | |
| 198 | if (!is_used_by_rpc() && _correlation_id != INVALID_BTHREAD_ID) { |
| 199 | CHECK_NE(EPERM, bthread_id_cancel(_correlation_id)); |
| 200 | } |
| 201 | if (_oncancel_id != INVALID_BTHREAD_ID) { |
| 202 | bthread_id_error(_oncancel_id, 0); |
| 203 | } |
| 204 | if (_pchan_sub_count > 0) { |
| 205 | DestroyParallelChannelDone(_done); |
| 206 | } |
| 207 | delete _sender; |
| 208 | _lb.reset(NULL); |
| 209 | _current_call.Reset(); |
| 210 | ExcludedServers::Destroy(_accessed); |
| 211 | _request_buf.clear(); |
| 212 | delete _http_request; |
| 213 | delete _http_response; |
| 214 | delete _request_user_fields; |
| 215 | delete _response_user_fields; |
| 216 | _request_attachment.clear(); |
| 217 | _response_attachment.clear(); |
| 218 | if (_wpa) { |
| 219 | _wpa->MarkRPCAsDone(Failed()); |
| 220 | _wpa.reset(NULL); |
| 221 | } |
| 222 | if (_rpa != NULL) { |
| 223 | if (!has_progressive_reader()) { |
| 224 | // Never called ReadProgressiveAttachmentBy (successfully), the data |
| 225 | // is probably being buffered and a full buffer may block parse |
| 226 | // handler of the protocol. We need to set a reader to consume |
| 227 | // the buffer. |
| 228 | pthread_once(&s_ignore_all_read_once, CreateIgnoreAllRead); |
| 229 | _rpa->ReadProgressiveAttachmentBy(s_ignore_all_read); |
| 230 | } |
| 231 | _rpa.reset(NULL); |
| 232 | } |
| 233 | delete _remote_stream_settings; |
| 234 | _thrift_method_name.clear(); |
| 235 | _after_rpc_resp_fn = nullptr; |
| 236 | |
| 237 | CHECK(_unfinished_call == NULL); |
| 238 | } |
| 239 | |
| 240 | void Controller::ResetPods() { |
| 241 | // NOTE: Make the sequence of assignments same with the order that they're |
nothing calls this directly
no test coverage detected