From 15b4767b17f78a827fd221e941c7ac7aa987e02f Mon Sep 17 00:00:00 2001 From: user Date: Fri, 17 Jul 2026 23:20:55 +0200 Subject: irc: keep the keyboard live during RX floods (poll input every pass) '/join #sl0p right after connect' looked broken: the main loop only polled input when net_recv_nb returned nothing, and 'continue'd on every received segment. During a big MOTD (irc.sl0p.foo's is ~60 lines of color art) that starved input for the whole ~20s flood - the OSK wouldn't even open, and keystrokes were dropped. gbtype input fared a bit better (buffered in the 64-byte console ring) but still wasn't serviced until the flood ended. Poll pollin()/pollcon() once every loop iteration regardless of RX, and only idle-sleep when a pass both received nothing and read no key. The protocol/join logic was already correct (verified: JOIN #sl0p is sent, accepted, and the client switches to [#sl0p] with topic + names) - this just makes typing responsive while messages are streaming. Verified against the live server: injecting /join #sl0p *during* the MOTD flood now joins immediately instead of waiting it out. (Note: '#' is on the OSK - third row, second from the end: 10,8,":;,=+*_!?()[]<>@#~" - just not obvious.) --- c/irc.c | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/c/irc.c b/c/irc.c index 551dca1..250738a 100644 --- a/c/irc.c +++ b/c/irc.c @@ -399,16 +399,22 @@ void main(void) { for (;;) { n = net_recv_nb(sock, seg, (unsigned char)sizeof(seg)); if (n == 0) { say("-!- disconnected"); break; } - if (n != 0xFE && n != 0xFF) { /* got a segment: drain hard */ - feed(seg, n); - idle = 0; - continue; - } + if (n != 0xFE && n != 0xFF) feed(seg, n); /* render a segment if any */ if (quitting) { say("-!- quit"); break; } + + /* Poll input EVERY pass, even mid-flood: otherwise a big MOTD (or a + * busy channel) starves the keyboard for its whole duration - the OSK + * won't even open, and keystrokes are dropped. That's what made + * '/join #sl0p right after connect' look broken. */ i = pollin(); /* OSK */ if (!i) i = pollcon(); /* hub-injected console bytes */ - if (i) { key(i); idle = 0; continue; } - if (++idle >= 4) { msleep(20); idle = 4; } /* settle when idle */ + if (i) key(i); + + if (n == 0xFE || n == 0xFF) { /* nothing received this pass */ + if (!i && ++idle >= 4) { msleep(20); idle = 4; } + } else { + idle = 0; /* actively receiving; don't sleep */ + } } net_close(sock); row_clear(); -- cgit v1.3.1-sl0p