Add check whether buffer is empty

This commit is contained in:
Sebastian Serth
2021-10-11 23:15:36 +02:00
parent 58e923abd8
commit 1891cdd69c
2 changed files with 5 additions and 1 deletions

View File

@ -112,7 +112,7 @@ class Runner::Connection
def on_close(_event) def on_close(_event)
Rails.logger.debug { "#{Time.zone.now.getutc}: Closing connection to #{@socket.url} with status: #{@status}" } Rails.logger.debug { "#{Time.zone.now.getutc}: Closing connection to #{@socket.url} with status: #{@status}" }
forward_message @buffer.flush forward_message @buffer.flush unless @buffer.empty?
# Depending on the status, we might want to destroy the runner at management. # Depending on the status, we might want to destroy the runner at management.
# This ensures we get a new runner on the next request. # This ensures we get a new runner on the next request.

View File

@ -38,6 +38,10 @@ class Runner::Connection::Buffer
remaining_buffer remaining_buffer
end end
def empty?
@line_buffer.empty? && @global_buffer.empty?
end
private private
def process_and_split(message_parts, stop: false) def process_and_split(message_parts, stop: false)