Skip to content

Commit 2495d7b

Browse files
committed
Ensure finish_output is only ever called once.
1 parent 2c3d6d9 commit 2495d7b

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

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

+7-2
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,15 @@ def write(chunk)
7171
end
7272
end
7373

74+
# This method should only be called from within the context of the output task.
7475
def close(error = nil)
75-
@stream.finish_output(error)
76+
if @stream
77+
@stream.finish_output(error)
78+
@stream = nil
79+
end
7680
end
7781

82+
# This method should only be called from within the context of the HTTP/2 stream.
7883
def stop(error)
7984
@task&.stop
8085
@task = nil
@@ -103,7 +108,7 @@ def passthrough(task)
103108
# GC.start
104109
end
105110

106-
@stream.finish_output
111+
self.close
107112
ensure
108113
@body&.close($!)
109114
@body = nil

0 commit comments

Comments
 (0)