Subject: iconify bugs: revisted

From: Chris Rankin <[email-masked]>
Date: Sat, 29 Jan 2000 16:16:53 +1100 (EST)

Based on Dominik's analysis and fix, I have determined the underlying
WHY:

PositiveWrite()
{
    ...

>>> fcntl(readPipes[module],F_SETFL,0);
    while ((e = read(readPipes[module],&targetWindow, sizeof(Window))) > 0)
    {
      if (HandleModuleInput(targetWindow, module, NULL) == 66)
      {
        ...
      }
    }
    if (e <= 0)
    {
      KillModule(module);
    }
>>> fcntl(readPipes[module],F_SETFL,O_NDELAY);

The code first calls fcntl() to disable non-blocking mode, so that the
first read() will wait if there is no data immediately available. The
key point is that HandleModuleInput() can call PositiveWrite() again,
and this is where things go horribly wrong. In the second
PositiveWrite() call, it disables non-blocking mode again and then
crucially RESTORES blocking mode when it exits instead of restoring
the descriptor's flags to what they were originally. Therefore the
original PositiveWrite invocation will try to re-read on a pipe where
non-blocking mode has been reenabled, which results in EAGAIN if no
data is available.

As the code stands at the moment, the two calls to fcntl() are (a)
wrong and (b) redundant now. However, we really shouldn't need to poll
the descriptor manually for data to arrive anyway - this is why UNIX
has the the select() or poll() system calls.

I could modify the code; however I'm a bit concerned about
unilaterally discarding all of Dominik's hard work before "the ink has
dried" :-). What do people think?

Chris.

--
Visit the official FVWM web page at <URL:http://www.fvwm.org/>.
To unsubscribe from the list, send "unsubscribe fvwm-workers" in the
body of a message to [email-masked].
To report problems, send mail to [email-masked]

---

From: Dominik Vogt <[email-masked]>
Date: Sat, 29 Jan 2000 14:28:55 +0100

> dried" :-). What do people think?

Actually fixing the bug was a matter of minutes.  The hard work
was to *find* it.  If your fix is better (and I'm sure it is now
that I understand the cause), feel free to dump all my code into
the dustbin.  A prominent comment about the possible recursion in
PosistiveWrite would be nice.

Bye

Dominik ^_^

--
Dominik Vogt, [email-masked]
Reply-To: [email-masked]
--
Visit the official FVWM web page at <URL:http://www.fvwm.org/>.
To unsubscribe from the list, send "unsubscribe fvwm-workers" in the
body of a message to [email-masked].
To report problems, send mail to [email-masked]