Skip to content

Commit 464eead

Browse files
committed
Ensure that reader task is stopped on close.
1 parent 6ce3fbe commit 464eead

File tree

2 files changed

+21
-2
lines changed

2 files changed

+21
-2
lines changed

lib/async/http/protocol/http2/connection.rb

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,14 @@ def start_connection
7070
end
7171

7272
def close(error = nil)
73-
@reader = nil
74-
7573
super
74+
75+
# Ensure the reader task is stopped.
76+
if @reader
77+
reader = @reader
78+
@reader = nil
79+
reader.stop
80+
end
7681
end
7782

7883
def write_frame(frame)

spec/async/http/protocol/shared_examples.rb

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,20 @@
3939
expect(client.scheme).to be == "http"
4040
end
4141

42+
context '#close' do
43+
it 'can close the connection' do
44+
Async do |task|
45+
response = client.get("/")
46+
expect(response).to be_success
47+
response.finish
48+
49+
client.close
50+
51+
expect(task.children).to be_empty
52+
end.wait
53+
end
54+
end
55+
4256
context "huge body", timeout: 600 do
4357
let(:body) {Protocol::HTTP::Body::File.open("/dev/zero", size: 512*1024**2)}
4458

0 commit comments

Comments
 (0)