From 38053466fd5404e9d1ffec5e9e83a559bfb97de3 Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Mon, 6 May 2024 20:51:16 +0200 Subject: [PATCH] Ignore timeout --- qutebrowser/misc/ipc.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/qutebrowser/misc/ipc.py b/qutebrowser/misc/ipc.py index 72159eab7..0dbb88ae0 100644 --- a/qutebrowser/misc/ipc.py +++ b/qutebrowser/misc/ipc.py @@ -168,6 +168,7 @@ class IPCServer(QObject): 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 @@ -261,6 +262,7 @@ class IPCServer(QObject): 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.") @@ -393,11 +395,23 @@ class IPCServer(QObject): 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()