From: Christian Heller Date: Wed, 1 Oct 2025 03:52:09 +0000 (+0200) Subject: Reset ping-timeout timer on each connection start. X-Git-Url: https://plomlompom.com/repos/?a=commitdiff_plain;h=1408a09ba7bb73912d22c2e249d9cdee5e21f246;p=ircplom Reset ping-timeout timer on each connection start. --- diff --git a/src/ircplom/client.py b/src/ircplom/client.py index d8e59b7..ed52219 100644 --- a/src/ircplom/client.py +++ b/src/ircplom/client.py @@ -817,7 +817,7 @@ class Client(ABC, ClientQueueMixin): 'Abstracts socket connection, loop over it, and handling messages from it.' conn: Optional[IrcConnection] = None _cls_conn: type[IrcConnection] = IrcConnection - _expected_pong = '' + _expected_pong: str def __init__(self, conn_setup: IrcConnSetup, channels: set[str], **kwargs ) -> None: @@ -849,6 +849,7 @@ class Client(ABC, ClientQueueMixin): except Exception as e: # pylint: disable=broad-exception-caught self._put(ExceptionEvent(CrashingException(e))) else: + self._expected_pong = '' self.db.connection_state = 'connected' self.caps.start_negotation() self.send('USER', self.db.user_wanted, diff --git a/src/ircplom/testing.py b/src/ircplom/testing.py index f7db844..c8bfdd6 100644 --- a/src/ircplom/testing.py +++ b/src/ircplom/testing.py @@ -194,7 +194,7 @@ class _Playbook: self.put_keypress('KEY_ENTER') elif context.startswith(_CHAR_SERVER_MSG): client = self._get_client(int(context[1:])) - assert isinstance(client.conn, _FakeIrcConnection) + assert isinstance(client.conn, _FakeIrcConnection), client.conn client.conn.put_server_msg(msg) else: break diff --git a/src/tests/pingpong.txt b/src/tests/pingpong.txt index f0e27fa..6f55468 100644 --- a/src/tests/pingpong.txt +++ b/src/tests/pingpong.txt @@ -1,8 +1,10 @@ > /connect foo.bar.baz foo:bar baz:foobarbazquux +| isupport-clear-in 1 .$ isupport cleared 1 .$ isupport:CHANTYPES set to: [#&] 1 .$ isupport:PREFIX set to: [(ov)@+] 1 .$ isupport:USERLEN set to: [10] +| isupport-clear-out 1 .$ caps cleared 1 .$ users cleared 1 .$ channels cleared @@ -14,9 +16,12 @@ 1 .$ realname set to: [baz] 1 .$ password set to: [bar] 1 .$ port set to: [6697] +| conn0-in 1 .$ connection_state set to: [connecting] 1 .$ connection_state set to: [connected] +| conn0-out , .$ CONNECTED +| conn1-in 1 .> CAP LS :302 1 .> USER foobarbazquux 0 * :baz 1 .> NICK :foo @@ -24,25 +29,34 @@ # ensure we PONG properly :0:1 .< PING :? 1 .> PONG :? +| conn1-out # ping on timeout, go on as normal if PONG received +| trigger-ping-in <0 FAKE_IRC_CONN_TIMEOUT_EXCEPTION 1 .> PING :what's up? +| trigger-ping-out :0:1 .< :*.?.net PONG *.?.net :what's up? :0:1 .< :*.?.net NOTICE * :*** Looking up your ident... 2 .< *** [ server] *** Looking up your ident... # another timeout instead of pong? disconnect -<0 FAKE_IRC_CONN_TIMEOUT_EXCEPTION -1 .> PING :what's up? +| full-timeout-in +repeat trigger-ping-in trigger-ping-out <0 FAKE_IRC_CONN_TIMEOUT_EXCEPTION 1 .$ connection_state set to: [broken: no timely PONG from server] -1 .$ isupport cleared -1 .$ isupport:CHANTYPES set to: [#&] -1 .$ isupport:PREFIX set to: [(ov)@+] -1 .$ isupport:USERLEN set to: [10] +repeat isupport-clear-in isupport-clear-out 1 .$ connection_state set to: [] 2 .$ DISCONNECTED +| full-timeout-out + +# on re-connect, ensure timer cleared, so won't trigger already on 1st timeout +> /window 1 +> /reconnect +repeat conn0-in conn0-out +2 .$ CONNECTED +repeat conn1-in conn1-out +repeat full-timeout-in full-timeout-out > /quit 0 .<