Skip to content
This repository was archived by the owner on Oct 22, 2020. It is now read-only.

Commit 3917bf9

Browse files
committed
Fix HTTP server not shutting down after unexpected errors
1 parent d4fe9f4 commit 3917bf9

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

lib/wpxf/net/http_server.rb

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ def start_http_server(non_block = false)
8686
def stop_http_server
8787
emit_info 'Stopping HTTP server...', true
8888
@http_server_kill_switch = true
89-
@http_server_thread.exit if @http_server_thread
89+
@http_server_thread&.exit
9090
@tcp_server.close if !@tcp_server.nil? && !@tcp_server.closed?
9191
emit_info 'HTTP server stopped'
9292
end
@@ -147,11 +147,10 @@ def http_server_loop
147147
rescue SignalException
148148
emit_warning 'Caught kill signal', true
149149
rescue StandardError => e
150-
emit_warning "Socket error: #{e}", true
150+
emit_error "Socket error: #{e}"
151151
end
152152

153-
@tcp_server.close if !@tcp_server.nil? && !@tcp_server.closed?
154-
@http_server_kill_switch = false
153+
stop_http_server
155154
end
156155

157156
def handle_incoming_http_request(socket)

0 commit comments

Comments
 (0)