Subject: Problem with non-atomic SendText

From: Matthias Clasen <[email-masked]>
Date: Sat, 13 Mar 1999 03:28:31 +0100

While working on that gtk module, I had the problem
that sometimes the module got killed while sending
some text back to fvwm. I traced the problem to the
following szenario:

module: enters SendText, writes the window id
fvwm: sees input, reads the window id, enters HandleModuleInput
       tries to read the packet size, doesn't get it and kills the module
module: now im gonna send the size...oops im dead!

I got around the problem by replacing SendText by the following
in my module:

void AtomicSendText(int *fd,char *message,unsigned long window)
{
  char *p, buf[1024]; /* should be ok; fvwm limits packet length to 1000 */
  int w;

  if(message != NULL)
  {
    p = buf;
    *((unsigned long*)p) = window;
    p += sizeof (unsigned long);
    w = strlen (message);
    *((int*)p) = w;
    p += sizeof (int);
    strncpy (p, message, 1000);
    p += w;
    *((int*)p) = 1;
    p += sizeof (int);

    write(fd[0], buf, p - buf);
  }
}

Would it be ok to replace SendText in libs/Module.c
by this atomic version ?

-- 
Matthias Clasen, 
Tel. 0761/203-5606
Email: [email-masked]
Mathematisches Institut, Albert-Ludwigs-Universitaet Freiburg
--
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: Dan Espen <[email-masked]>
Date: Sat, 13 Mar 1999 20:16:10 -0500

> I got around the problem by replacing SendText by the following
... (send text in 1 large block)
> Would it be ok to replace SendText in libs/Module.c

Why are  you asking?  Is  there  some drawback I    don't see?  I  was
thinking of making the  same change  myself  (I thought it  might help
performance.)  If it breaks some modules, now is the time to do it.

--
Dan Espen
444 Hoes Lane  Room RRC 1C-214           E-mail: [email-masked]
Piscataway, NJ 08854                     Phone: (732) 699-5570
--
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: Matthias Clasen <[email-masked]>
Date: Mon, 15 Mar 1999 15:06:05 +0100

> performance.)  If it breaks some modules, now is the time to do it.

I just didn't feel too comfortable with replacing one of the central
routines for fvwm<->module communication without asking first. I'll commit
the atomic version tonight from home.

Matthias