Skip to content

Commit 679ab3e

Browse files
MrSerthDome-GER
authored andcommitted
Prevent duplicate close of client connection
When a running execution is stopped by the client (through the WebSocket connection), we immediately call `close_client_connection` to terminate Tubesock connection to the browser and stop the runner. However, since the regular workflow also included a call to `close_client_connection`, it might have been called twice.
1 parent 40cb082 commit 679ab3e

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

app/controllers/submissions_controller.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -338,6 +338,8 @@ def authorize!
338338
end
339339

340340
def close_client_connection(client_socket)
341+
return if client_socket&.closed?
342+
341343
# search for errors and save them as StructuredError (for scoring runs see submission.rb)
342344
errors = extract_errors
343345
send_hints(client_socket, errors)
@@ -409,7 +411,7 @@ def send_and_store(client_socket, message)
409411
end
410412
@testrun[:messages].push message
411413
@testrun[:status] = message[:status] if message[:status]
412-
client_socket.send_data(message.to_json)
414+
client_socket&.send_data(message.to_json)
413415
end
414416

415417
def max_output_buffer_size

0 commit comments

Comments
 (0)