Skip to content

Commit

Permalink
Ignore timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
The-Compiler committed May 6, 2024
1 parent 963c466 commit c48e3bc
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions qutebrowser/misc/ipc.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ def __init__(self, socketname, parent=None):
self._timer = usertypes.Timer(self, 'ipc-timeout')
self._timer.setInterval(READ_TIMEOUT)
self._timer.timeout.connect(self.on_timeout)
self._timer_start_time = None

if utils.is_windows: # pragma: no cover
self._atime_timer = None
Expand Down Expand Up @@ -261,6 +262,7 @@ def handle_connection(self):
log.ipc.debug("Client connected (socket {}).".format(self._socket_id))
self._socket = socket
self._timer.start()
self._timer_start_time = time.monotonic()
socket.readyRead.connect(self.on_ready_read)
if socket.canReadLine():
log.ipc.debug("We can read a line immediately.")
Expand Down Expand Up @@ -393,11 +395,23 @@ def on_ready_read(self):

if self._socket is not None:
self._timer.start()
self._timer_start_time = time.monotonic()

@pyqtSlot()
def on_timeout(self):
"""Cancel the current connection if it was idle for too long."""
assert self._socket is not None
assert self._timer_start_time is not None
if (
time.monotonic() - self._timer_start_time < READ_TIMEOUT / 1000 / 10
and qtutils.version_check("6.7.0", exact=True, compiled=False)
and utils.is_windows
):
# WORKAROUND for unknown Qt bug (?) where the timer triggers immediately
# https://github.com/qutebrowser/qutebrowser/issues/8191
log.ipc.debug("Ignoring early on_timeout call")
return

log.ipc.error("IPC connection timed out "
"(socket {}).".format(self._socket_id))
self._socket.disconnectFromServer()
Expand Down

0 comments on commit c48e3bc

Please sign in to comment.