-
Notifications
You must be signed in to change notification settings - Fork 848
Add logic to clean up vios on HttpSM shutdown #4020
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -128,16 +128,18 @@ std::atomic<int64_t> next_sm_id(0); | |
|
|
||
| ClassAllocator<HttpSM> httpSMAllocator("httpSMAllocator"); | ||
|
|
||
| HttpVCTable::HttpVCTable() | ||
| HttpVCTable::HttpVCTable(HttpSM *mysm) | ||
| { | ||
| memset(&vc_table, 0, sizeof(vc_table)); | ||
| sm = mysm; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use member initializer. E.g. |
||
| } | ||
|
|
||
| HttpVCTableEntry * | ||
| HttpVCTable::new_entry() | ||
| { | ||
| for (int i = 0; i < vc_table_max_entries; i++) { | ||
| if (vc_table[i].vc == nullptr) { | ||
| vc_table[i].sm = sm; | ||
| return vc_table + i; | ||
| } | ||
| } | ||
|
|
@@ -191,6 +193,26 @@ HttpVCTable::remove_entry(HttpVCTableEntry *e) | |
| free_MIOBuffer(e->write_buffer); | ||
| e->write_buffer = nullptr; | ||
| } | ||
| if (e->read_vio != nullptr && e->read_vio->cont == sm) { | ||
| // Cleanup dangling i/o | ||
| if (e == sm->get_ua_entry() && sm->get_ua_txn() != nullptr) { | ||
| e->read_vio = sm->get_ua_txn()->do_io_read(nullptr, 0, nullptr); | ||
| } else if (e == sm->get_server_entry() && sm->get_server_session()) { | ||
| e->read_vio = sm->get_server_session()->do_io_read(nullptr, 0, nullptr); | ||
| } else { | ||
| ink_release_assert(false); | ||
| } | ||
| } | ||
| if (e->write_vio != nullptr && e->write_vio->cont == sm) { | ||
| // Cleanup dangling i/o | ||
| if (e == sm->get_ua_entry() && sm->get_ua_txn()) { | ||
| e->write_vio = sm->get_ua_txn()->do_io_write(nullptr, 0, nullptr); | ||
| } else if (e == sm->get_server_entry() && sm->get_server_session()) { | ||
| e->write_vio = sm->get_server_session()->do_io_write(nullptr, 0, nullptr); | ||
| } else { | ||
| ink_release_assert(false); | ||
| } | ||
| } | ||
| e->read_vio = nullptr; | ||
| e->write_vio = nullptr; | ||
| e->vc_handler = nullptr; | ||
|
|
@@ -258,9 +280,8 @@ HttpVCTable::cleanup_all() | |
| default_handler = _h; \ | ||
| } | ||
|
|
||
| HttpSM::HttpSM() : Continuation(nullptr) | ||
| HttpSM::HttpSM() : Continuation(nullptr), vc_table(this) | ||
| { | ||
| ink_zero(vc_table); | ||
| ink_zero(http_parser); | ||
| } | ||
|
|
||
|
|
@@ -1753,8 +1774,9 @@ HttpSM::state_http_server_open(int event, void *data) | |
| do_http_server_open(); | ||
| } | ||
| break; | ||
| case VC_EVENT_ERROR: | ||
| case VC_EVENT_INACTIVITY_TIMEOUT: | ||
| case VC_EVENT_ACTIVE_TIMEOUT: | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Where was
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The active timeout was not handled before. Ran across it while debugging the ASYNC job. Should be handled here. I can pull it into a separate PR if necessary. |
||
| case VC_EVENT_ERROR: | ||
| case NET_EVENT_OPEN_FAILED: | ||
| t_state.current.state = HttpTransact::CONNECTION_ERROR; | ||
| // save the errno from the connect fail for future use (passed as negative value, flip back) | ||
|
|
@@ -2659,7 +2681,10 @@ HttpSM::tunnel_handler_post(int event, void *data) | |
| if (ua_entry->write_buffer) { | ||
| free_MIOBuffer(ua_entry->write_buffer); | ||
| ua_entry->write_buffer = nullptr; | ||
| ua_entry->vc->do_io_write(this, 0, nullptr); | ||
| ua_entry->vc->do_io_write(nullptr, 0, nullptr); | ||
| } | ||
| if (!p->handler_state) { | ||
| p->handler_state = HTTP_SM_POST_UA_FAIL; | ||
| } | ||
| break; | ||
| case VC_EVENT_READ_READY: | ||
|
|
@@ -2996,6 +3021,11 @@ HttpSM::tunnel_handler_server(int event, HttpTunnelProducer *p) | |
| ink_assert(p->vc_type == HT_HTTP_SERVER); | ||
| ink_assert(p->vc == server_session); | ||
|
|
||
| // The server session has been released. Clean all pointer | ||
| // Calling remove_entry instead of server_entry because we don't | ||
| // want to close the server VC at this point | ||
| vc_table.remove_entry(server_entry); | ||
|
|
||
| if (close_connection) { | ||
| p->vc->do_io_close(); | ||
| p->read_vio = nullptr; | ||
|
|
@@ -3027,9 +3057,6 @@ HttpSM::tunnel_handler_server(int event, HttpTunnelProducer *p) | |
| } | ||
| } | ||
|
|
||
| // The server session has been released. Clean all pointer | ||
| server_entry->in_tunnel = true; // to avid cleaning in clenup_entry | ||
| vc_table.cleanup_entry(server_entry); | ||
| server_session = nullptr; // Because p->vc == server_session | ||
| server_entry = nullptr; | ||
|
|
||
|
|
@@ -3410,7 +3437,7 @@ HttpSM::tunnel_handler_post_ua(int event, HttpTunnelProducer *p) | |
| // if it is active timeout case, we need to give another chance to send 408 response; | ||
| ua_txn->set_active_timeout(HRTIME_SECONDS(t_state.txn_conf->transaction_active_timeout_in)); | ||
|
|
||
| p->vc->do_io_write(this, 0, nullptr); | ||
| p->vc->do_io_write(nullptr, 0, nullptr); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah, that's how you stop repeat shutdowns. |
||
| p->vc->do_io_shutdown(IO_SHUTDOWN_READ); | ||
|
|
||
| return 0; | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why the parentheses around
client_vc?