mudgangster

Tiny, scriptable MUD client
Log | Files | Refs

commit 1c2dba83d60f0d22dbb6895abde0e9b0509319a2
parent 8fb2df5539f47517b64048e111fdeb69a03e3cbf
Author: Michael Savage <mikejsavage@gmail.com>
Date:   Sun,  6 Jan 2019 19:16:33 +0200

Fire intervals after every poll, so typing etc doesn't block them

Diffstat:
src/x11.cc | 39++++++++++++++++++---------------------
1 file changed, 18 insertions(+), 21 deletions(-)

diff --git a/src/x11.cc b/src/x11.cc @@ -591,27 +591,24 @@ void event_loop() { if( ok == -1 ) FATAL( "poll" ); - if( ok == 0 ) { - script_fire_intervals(); - } - else { - for( size_t i = 1; i < ARRAY_COUNT( fds ); i++ ) { - if( fds[ i ].revents & POLLIN ) { - Socket * sock = socket_from_fd( fds[ i ].fd ); - assert( sock != NULL ); - - char buf[ 8192 ]; - size_t n; - TCPRecvResult res = net_recv( sock->sock, buf, sizeof( buf ), &n ); - if( res == TCP_OK ) { - script_socketData( sock, buf, n ); - } - else if( res == TCP_CLOSED ) { - script_socketData( sock, NULL, 0 ); - } - else { - FATAL( "net_recv" ); - } + script_fire_intervals(); + + for( size_t i = 1; i < ARRAY_COUNT( fds ); i++ ) { + if( fds[ i ].revents & POLLIN ) { + Socket * sock = socket_from_fd( fds[ i ].fd ); + assert( sock != NULL ); + + char buf[ 8192 ]; + size_t n; + TCPRecvResult res = net_recv( sock->sock, buf, sizeof( buf ), &n ); + if( res == TCP_OK ) { + script_socketData( sock, buf, n ); + } + else if( res == TCP_CLOSED ) { + script_socketData( sock, NULL, 0 ); + } + else { + FATAL( "net_recv" ); } } }