Skip to content

Commit

Permalink
Ensure finish_output is only ever called once.
Browse files Browse the repository at this point in the history
  • Loading branch information
ioquatix committed Apr 3, 2020
1 parent 2c3d6d9 commit 2495d7b
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions lib/async/http/protocol/http2/output.rb
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,15 @@ def write(chunk)
end
end

# This method should only be called from within the context of the output task.
def close(error = nil)
@stream.finish_output(error)
if @stream
@stream.finish_output(error)
@stream = nil
end
end

# This method should only be called from within the context of the HTTP/2 stream.
def stop(error)
@task&.stop
@task = nil
Expand Down Expand Up @@ -103,7 +108,7 @@ def passthrough(task)
# GC.start
end

@stream.finish_output
self.close
ensure
@body&.close($!)
@body = nil
Expand Down

0 comments on commit 2495d7b

Please sign in to comment.