bug-ncurses
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: wgetch_events blocks unnecessarily


From: Bernd Jendrissek
Subject: Re: wgetch_events blocks unnecessarily
Date: Tue, 30 May 2006 13:59:13 +0200
User-agent: Mutt/1.4.2.1i

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Sat, May 27, 2006 at 11:52:39AM -0400, Thomas Dickey wrote:
> that's probably right - it's only an experimental option with no
> documentation (other than ncurses/README.IZ) and no demonstration or
> test-program.  So I didn't add a configure option for it...

I just noticed my .spec file has -DNCURSES_WGETCH_EVENTS but thanks for
this, it helps the conceptual consistency.  FWIW I did manage to muddle
through with the doc, but I also think an example would have helped.
Wouldn't lynx just *love* to use wgetch_events?

> thanks for the bug-report

Glad to do what I can; as soon as I get my employer to sign a disclaimer
I hope I can submit more patches instead of relying on eager beavers.

> >maybe some other unencumbered eager beaver can recreate the fix.
> 
> ;-)

Heh, I see they and the elves have been busy.  I haven't actually tried
your patch (Real Soon) but it looks like it hits the same spots.  AFAICT
there's a little bit more to do:

ncurses-5.5/ncurses/tty/lib_twait.c:_nc_timed_wait:425
            result = 0;
#if USE_FUNC_POLL
            for (count = 0; count < 2; count++) {
                if ((mode & (1 << count))
                    && (fds[count].revents & POLLIN)) {
                    result |= (1 << count);
                }

This is problematic if there is no SP->_mouse_fd but the caller still
requested mode with bit 1 set; in this case _nc_timed_wait() will be
accessing an uninitialized fds[count].revents.

The next problem is in
ncurses-5.5/ncurses/base/lib_getch.c:fifo_push:167
        n = 1;
    } else
#endif
    {                           /* Can block... */
        unsigned char c2 = 0;
        n = read(SP->_ifd, &c2, 1);
        ch = c2;
    }

#ifdef HIDE_EINTR

This branch executes regardless of whether keyboard input is available
or not; perhaps one could set stdin to nonblocking mode, but I added an
if() clause on evl being NULL or mask indicating keyboard readiness.

Sorry for the English-language patch, but I'd rather be paranoid than
sorry!

- -- 
/"\  ASCII Ribbon Campaign - against html email
\ /                        - against microsoft office attachments
 X                         - against text above fullquote below
/ \                        - against lines longer than 79 characters
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2 (GNU/Linux)
Comment: Please fetch my new key 804177F8 from hkp://wwwkeys.eu.pgp.net/

iD8DBQFEfDOMwyMv24BBd/gRAjnsAJ0eRLW5Jxc9tghkuL+Os0i8epInmgCfYnpX
zQKZ18qRWJz0Zg0OguWwAeE=
=jeJl
-----END PGP SIGNATURE-----




reply via email to

[Prev in Thread] Current Thread [Next in Thread]