Make the webconfig HTTP server threaded, fixing a Safari hang

Recently Safari seems to hang with fish webconfig. This is apparently
because Safari is opening a socket and not writing to it, causing
webconfig to hang until the timeout (30 seconds). It's not clear why.

Use ThreadingMixIn so that FishConfigTCPServer can handle more
than one connection at a time. This fixes the hang under Safari.
This commit is contained in:
ridiculousfish 2021-05-05 13:29:55 -07:00
parent fa74dc977b
commit f25b9f9831

View File

@ -865,7 +865,7 @@ class BindingParser:
return readable_command + result
class FishConfigTCPServer(SocketServer.TCPServer):
class FishConfigTCPServer(SocketServer.ThreadingMixIn, SocketServer.TCPServer):
"""TCPServer that only accepts connections from localhost (IPv4/IPv6)."""
WHITELIST = set(["::1", "::ffff:127.0.0.1", "127.0.0.1"])
@ -1575,6 +1575,11 @@ def runThing():
thread = threading.Thread(target=runThing)
thread.start()
# Safari will open sockets and not write to them, causing potential hangs
# on shutdown.
httpd.block_on_close = False
httpd.daemon_threads = True
# Select on stdin and httpd
stdin_no = sys.stdin.fileno()
try: