Subject: perl module problem

From: Jochen Klenner <[email-masked]>
Date: Thu, 2 Oct 2003 01:56:00 +0200 (MEST)

Hi all

I found the following problem while writing a perl module. Fvwm version is
2.5.8. Instruction to reproduce:

Fire up fvwm with an empty config. Open a console and start the attached
module like this
Module /path/to/module netscape Netscape
The stuff sent to fvwm when the window is mapped doesn't seem to get
through, i.e. netscape's window decoration stays red. The following echo
command isn't executed either. The send commands at the start of the
script work flawlessly. When I issue the DestroyStyle in a
fvwmconsole afterwards, it works as expected.
By the way, the Netscape version is 4.61.
With other programs (e.g. emacs, xterm), the behavior is quite
inconsistent. Sometimes it works right, sometimes not, without a
conceivable pattern.

I found out that the script functions when it sleeps for a second before
the critical send commands (see the commented out line in the example
script).

Best regards

Jochen

---

From: Mikhael Goikhman <[email-masked]>
Date: Sat, 4 Oct 2003 02:25:17 +0300

> the critical send commands (see the commented out line in the example

I don't see anything that may be a perllib error. It seems like a timing
problem between fvwm and modules. I see (use FvwmGtkDebug) that on the
new window creation fvwm sends packets M_ADD_WINDOW and two M_MAP.
I don't know why it sends two M_MAP-s.

So, it is possible, for example, that if you send DestroyStyle command
between these M_MAP-s, this command is ignored, but it is not ignored
after the second M_MAP. Can you please investigate this?

Alternativelly, can you try to reproduce the problem with FvwmEvent
instead of your own perl-based module?

> my $module = new FVWM::Module(Mask => M_MAP, EnableOptions => 1);

The EnableOptions argument should be hash, not boolean.
And if the module mask is not explicitelly set, it is guessed from the
defined event handlers (in cvs), so this line may be reduced to just:

  my $module = new FVWM::Module;

Regards,
Mikhael.
--
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: Jochen Klenner <[email-masked]>
Date: Mon, 6 Oct 2003 03:20:19 +0200 (MEST)

> after the second M_MAP. Can you please investigate this?

I tried to wait for the second map event - see the attached script - and
it works. I will use the sleep 1 workaround in production code though. Who
knows how long the strange second M_MAP event will stay with us.

> instead of your own perl-based module?

Tried this, too, with the following commands:
*FvwmEvent: Cmd Echo
*FvwmEvent: map "map"
Module FvwmEvent

It works, I can actually see both "map"s in the output. This doesn't
surprise me much, if I think about it. If the map event didn't work in
FvwmEvent, somebody would probably have noticed earlier.

>   my $module = new FVWM::Module;

Yup, verified this, too.

By the way, no need to cc me, I'm on the list.

Best regards

Jochen

---

From: Mikhael Goikhman <[email-masked]>
Date: Mon, 6 Oct 2003 14:03:35 +0300

On 06 Oct 2003 03:20:19 +0200, Jochen Klenner wrote:
> > > I found the following problem while writing a perl module. Fvwm
> > > version is 2.5.8. Instruction to reproduce:
> > >

But you didn't send any DestroyStyle command in this test.

Surelly, any module (in Perl or not) sees the same events, 2 map events
in our case. This is not the problem, If I understand you, the problem is
that DestroyStyle after the first map is ignored. I don't have your
system and applications, so I may have different timing results.
I actually never was able to reproduce your original problem.

Here is a proper test, please confirm that it has the same problems:

*FvwmEvent-NetscapeTest: Cmd
*FvwmEvent-NetscapeTest: map NetscapeDestroyStyleAndExit

DestroyFunc NetscapeDestroyStyleAndExit
AddToFunc   NetscapeDestroyStyleAndExit
+ I ThisWindow (!Netscape) break
+ I Echo Got M_MAP for Netscape
+ I KillModule FvwmEvent FvwmEvent-NetscapeTest
+ I DestroyStyle Netscape

# repeat these 3 commands as many times as needed
Module FvwmEvent FvwmEvent-NetscapeTest
Style Netscape !Borders
Exec exec netscape

If it does not show problems then use the same technique in your script,
create a function at the start and execute it on the first "map".
If it shows the same problem then you can do nothing other than waiting
for the fix in fvwm.

Regards,
Mikhael.

---

From: Jochen Klenner <[email-masked]>
Date: Mon, 13 Oct 2003 02:20:43 +0200 (MEST)

Sorry for the late reply, I did some more tests.

> Module FvwmEvent FvwmEvent-NetscapeTest

I tried that, it works as expected.

> If it shows the same problem then you can do nothing other than waiting

I tested this, too, the script is attached. It fails again. Neither the
DestroyStyle nor the Beep nor the Echo command is executed (as before, the
echo at startup works allright). I tried it it with xterm instead of
netscape, and it turns out that this works *sometimes*. But either all
three commands make it or none of them.
This behavior is the reason why I didn't check DestroyStyle with FvwmEvent
at the first time.

This bug might well be timing-related, as you already conjectured. Maybe
it only shows up on my obsolete system. FYI it's an old PII with Linux
2.2.10 and Xfree86 3.3.4.

Best regards

Jochen

---

From: Jochen Klenner <[email-masked]>
Date: Mon, 13 Oct 2003 18:54:48 +0200 (MEST)

Lost my mind, in my latest mail I forgot the attachment. OK, here it is.

Best regards

Jochen

---

From: Mikhael Goikhman <[email-masked]>
Date: Wed, 15 Oct 2003 00:42:57 +0300

On 13 Oct 2003 02:20:43 +0200, Jochen Klenner wrote:
> 
> I tested this, too, the script is attached.
> 
> It fails again. Neither the DestroyStyle nor the Beep nor the Echo
> command is executed (as before, the echo at startup works allright). I
> tried it it with xterm instead of netscape, and it turns out that this
> works *sometimes*. But either all three commands make it or none of
> them. This behavior is the reason why I didn't check DestroyStyle with
> FvwmEvent at the first time.
> 

I have PII too, but the more updated software.

After some fidling, I can reproduce the problem with Netscape, but not
with other programs and really sometimes.

I think the problem happens only with modules that send some command
to fvwm and immediatelly terminate themselves. I tried to see whether
I can do anything on the perllib side, and I think that everything
possible is done, the pipes are flushed and properly closed. I will
see later whether something may be done on the fvwm side.

There are 2 solutions for you.

1) Add sleep(5) before terminate(), it should not affect the module
logic.

2) Don't make the module terminate itself, ask fvwm for KillModule.
You may nulify the module mask after doing this if needed.

Regards,
Mikhael.