-
Notifications
You must be signed in to change notification settings - Fork 844
Fix H3 transaction leak #9714
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
Merged
Merged
Fix H3 transaction leak #9714
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -120,7 +120,7 @@ HQTransaction::do_io_read(Continuation *c, int64_t nbytes, MIOBuffer *buf) | |
|
|
||
| if (buf) { | ||
| this->_process_read_vio(); | ||
| this->_send_tracked_event(this->_read_event, VC_EVENT_READ_READY, &this->_read_vio); | ||
| this->_read_event = this->_send_tracked_event(this->_read_event, VC_EVENT_READ_READY, &this->_read_vio); | ||
| } | ||
|
|
||
| return &this->_read_vio; | ||
|
|
@@ -145,7 +145,7 @@ HQTransaction::do_io_write(Continuation *c, int64_t nbytes, IOBufferReader *buf, | |
| if (c != nullptr && nbytes > 0) { | ||
| // TODO Return nullptr if the stream is not on writable state | ||
| this->_process_write_vio(); | ||
| this->_send_tracked_event(this->_write_event, VC_EVENT_WRITE_READY, &this->_write_vio); | ||
| this->_write_event = this->_send_tracked_event(this->_write_event, VC_EVENT_WRITE_READY, &this->_write_vio); | ||
| } | ||
|
|
||
| return &this->_write_vio; | ||
|
|
@@ -173,8 +173,6 @@ HQTransaction::do_io_close(int lerrno) | |
| this->_write_vio.nbytes = 0; | ||
| this->_write_vio.op = VIO::NONE; | ||
| this->_write_vio.cont = nullptr; | ||
|
|
||
| this->_proxy_ssn->do_io_close(lerrno); | ||
| } | ||
|
|
||
| void | ||
|
|
@@ -208,6 +206,7 @@ HQTransaction::transaction_done() | |
| { | ||
| // TODO: start closing transaction | ||
| super::transaction_done(); | ||
| delete this; | ||
| return; | ||
| } | ||
|
|
||
|
|
@@ -327,10 +326,19 @@ Http3Transaction::Http3Transaction(Http3Session *session, QUICStreamVCAdapter::I | |
|
|
||
| Http3Transaction::~Http3Transaction() | ||
| { | ||
| Http3TransDebug("Delete transaction"); | ||
|
|
||
| // This should have already been called but call it here just incase. | ||
| do_io_close(); | ||
|
|
||
| delete this->_header_framer; | ||
| this->_header_framer = nullptr; | ||
| delete this->_data_framer; | ||
| this->_data_framer = nullptr; | ||
| delete this->_header_handler; | ||
| this->_header_handler = nullptr; | ||
| delete this->_data_handler; | ||
| this->_data_handler = nullptr; | ||
| } | ||
|
|
||
| int | ||
|
|
@@ -355,6 +363,9 @@ Http3Transaction::state_stream_open(int event, void *edata) | |
| switch (event) { | ||
| case VC_EVENT_READ_READY: | ||
| Http3TransVDebug("%s (%d)", get_vc_event_name(event), event); | ||
| if (this->_read_event == edata) { | ||
| this->_read_event = nullptr; | ||
| } | ||
| // if no progress, don't need to signal | ||
| if (this->_process_read_vio() > 0) { | ||
| this->_signal_read_event(); | ||
|
|
@@ -375,6 +386,9 @@ Http3Transaction::state_stream_open(int event, void *edata) | |
| this->_info.read_vio->reenable(); | ||
| break; | ||
| case VC_EVENT_WRITE_READY: | ||
| if (this->_write_event == edata) { | ||
| this->_write_event = nullptr; | ||
| } | ||
| Http3TransVDebug("%s (%d)", get_vc_event_name(event), event); | ||
| // if no progress, don't need to signal | ||
| if (this->_process_write_vio() > 0) { | ||
|
|
@@ -410,11 +424,17 @@ Http3Transaction::state_stream_closed(int event, void *data) | |
|
|
||
| switch (event) { | ||
| case VC_EVENT_READ_READY: | ||
| if (this->_read_event == data) { | ||
| this->_read_event = nullptr; | ||
| } | ||
| case VC_EVENT_READ_COMPLETE: { | ||
| // ignore | ||
| break; | ||
| } | ||
| case VC_EVENT_WRITE_READY: | ||
| if (this->_write_event == data) { | ||
| this->_write_event = nullptr; | ||
| } | ||
| case VC_EVENT_WRITE_COMPLETE: { | ||
| // ignore | ||
| break; | ||
|
|
@@ -547,6 +567,10 @@ Http09Transaction::state_stream_open(int event, void *edata) | |
|
|
||
| switch (event) { | ||
| case VC_EVENT_READ_READY: | ||
| if (this->_read_event == edata) { | ||
| this->_read_event = nullptr; | ||
| } | ||
| [[fallthrough]]; | ||
| case VC_EVENT_READ_COMPLETE: { | ||
| int64_t len = this->_process_read_vio(); | ||
| // if no progress, don't need to signal | ||
|
|
@@ -558,6 +582,10 @@ Http09Transaction::state_stream_open(int event, void *edata) | |
| break; | ||
| } | ||
| case VC_EVENT_WRITE_READY: | ||
| if (this->_write_event == edata) { | ||
| this->_write_event = nullptr; | ||
| } | ||
| [[fallthrough]]; | ||
| case VC_EVENT_WRITE_COMPLETE: { | ||
| int64_t len = this->_process_write_vio(); | ||
| if (len > 0) { | ||
|
|
@@ -595,11 +623,17 @@ Http09Transaction::state_stream_closed(int event, void *data) | |
|
|
||
| switch (event) { | ||
| case VC_EVENT_READ_READY: | ||
| if (this->_read_event == data) { | ||
| this->_read_event = nullptr; | ||
| } | ||
|
Contributor
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. funny the way complier complains about |
||
| case VC_EVENT_READ_COMPLETE: { | ||
| // ignore | ||
| break; | ||
| } | ||
| case VC_EVENT_WRITE_READY: | ||
| if (this->_write_event == data) { | ||
| this->_write_event = nullptr; | ||
| } | ||
| case VC_EVENT_WRITE_COMPLETE: { | ||
| // ignore | ||
| break; | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
I am always scare about this
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.
I'm not a big fun of this pattern too, but this is probably the right place to delete/free/release transaction instance if we follow the design. H2 tries to free transactions here and there and it's a mess, but If you look at H1ClientTransaction, it's released here in
transaction_done().