Skip to content

Commit 1ac7ff9

Browse files
committed
Delete H2 stream before destroy
1 parent 6dcc822 commit 1ac7ff9

File tree

2 files changed

+14
-6
lines changed

2 files changed

+14
-6
lines changed

proxy/http2/Http2Stream.cc

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -123,9 +123,7 @@ Http2Stream::main_event_handler(int event, void *edata)
123123
}
124124
reentrancy_count--;
125125
// Clean stream up if the terminate flag is set and we are at the bottom of the handler stack
126-
if (terminate_stream && reentrancy_count == 0) {
127-
destroy();
128-
}
126+
terminate_if_possible();
129127

130128
return 0;
131129
}
@@ -359,9 +357,18 @@ Http2Stream::transaction_done()
359357
ink_assert(cross_thread_event == nullptr);
360358
// Schedule the destroy to occur after we unwind here. IF we call directly, may delete with reference on the stack.
361359
terminate_stream = true;
362-
if (terminate_stream && reentrancy_count == 0) {
363-
destroy();
364-
}
360+
terminate_if_possible();
361+
}
362+
}
363+
364+
void
365+
HttpStream::terminate_if_possible()
366+
{
367+
if (terminate_stream && reentrancy_count == 0) {
368+
Http2ClientSession *h2_parent = static_cast<Http2ClientSession *>(parent);
369+
SCOPED_MUTEX_LOCK(lock, h2_parent->connection_state.mutex, this_ethread());
370+
h2_parent->connection_state.delete_stream(this);
371+
destroy();
365372
}
366373
}
367374

proxy/http2/Http2Stream.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,7 @@ class Http2Stream : public ProxyClientTransaction
147147
VIO *do_io_write(Continuation *c, int64_t nbytes, IOBufferReader *abuffer, bool owner = false) override;
148148
void do_io_close(int lerrno = -1) override;
149149
void initiating_close();
150+
void terminate_if_possible();
150151
void do_io_shutdown(ShutdownHowTo_t) override {}
151152
void update_read_request(int64_t read_len, bool send_update);
152153
bool update_write_request(IOBufferReader *buf_reader, int64_t write_len, bool send_update);

0 commit comments

Comments
 (0)