From xemacs-m  Tue Apr 15 21:36:05 1997
Received: from pentagana.sonic.jp (jhod@tc-4-021.tokyo.gol.com [202.243.49.21])
	by xemacs.org (8.8.5/8.8.5) with ESMTP id VAA05751
	for <xemacs-beta@xemacs.org>; Tue, 15 Apr 1997 21:35:34 -0500 (CDT)
Received: (from jhod@localhost) by pentagana.sonic.jp (8.7.1+2.6Wbeta4/3.4W3) id LAA00226; Wed, 16 Apr 1997 11:23:50 +0900
To: xemacs-beta@xemacs.org
Cc: dunham@dunham.tcimet.net
Subject: Re: bug report(xemacs-20.1 + Mule + Wnn crashes)
References: <9704140220.AA02100@hrs102.rs.kyoto.omronsoft.co.jp> <m2pvvwhp10.fsf@dunham.tcimet.net>
From: jhod@po.iijnet.or.jp (P. E. Jareth Hein)
In-Reply-To: Steve Dunham's message of 15 Apr 1997 00:45:43 -0400
Mime-Version: 1.0 (generated by tm-edit 7.106)
Content-Type: multipart/mixed;
 boundary="Multipart_Wed_Apr_16_11:23:46_1997-1"
Content-Transfer-Encoding: 7bit
Date: 16 Apr 1997 11:23:46 +0900
Message-ID: <u4g1wrln7x.fsf@pentagana.sonic.jp>
Lines: 107
X-Mailer: Gnus v5.4.45/XEmacs 20.1(beta15)

--Multipart_Wed_Apr_16_11:23:46_1997-1
Content-Type: text/plain; charset=US-ASCII

Steve Dunham <dunham@dunham.tcimet.net> writes:

> -=-TSUTOMU NAKAMURA-=- <tsutomu@rs.kyoto.omronsoft.co.jp> writes:

[Nakamura-san's bug report relating to Wnn, XEmacs and SIGALRM snipped]
> 
> I recently discovered this problem too. I just removed the alarm stuff
> from Wnn. After that everything worked fine.  There is a unified diff
> below for WNN.
> 
> 
> Steve
> dunham@cps.msu.edu
> 
> 
> --- Xsi.orig/Wnn/jlib/js.c      Thu Aug 18 21:30:29 1994
> +++ Xsi/Wnn/jlib/js.c   Thu Apr  3 23:53:25 1997
> @@ -290,15 +290,7 @@
>         return -1 ;
>      }
>  
> -    if (timeout != 0 && timeout > 0) {
> -       signal(SIGALRM, connect_timeout);
> -       alarm(timeout);
> -    }
>      ret = connect(sd, (caddr_t)&saddr_in, sizeof(saddr_in));
> -    if (timeout != 0 && timeout > 0) {
> -       alarm(0);
> -       signal(SIGALRM, SIG_IGN);
> -    }
>      if (ret == ERROR) {
>  #if DEBUG
>         xerror("jslib:Can't connect Inet socket.\n");

Steve, thanks for the thought, but this isn't quite the right
approach. First off, fixing a lib for a program crash is usually the
last resort (what if a new upstream version comes along?). And the
above patch is not strictly kosher either as it completly removes the
timeout capability, negating the API. The correct patch is below, and
changes our code to properly deal with timeouts around whatever the
library does.

--Jareth


--Multipart_Wed_Apr_16_11:23:46_1997-1
Content-Type: application/octet-stream; type=patch
Content-Disposition: attachment; filename="wnn.diff"
Content-Transfer-Encoding: 7bit

Index: src/mule-wnnfns.c
===================================================================
RCS file: /CVSroot/XEmacs/src/mule-wnnfns.c,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 mule-wnnfns.c
--- mule-wnnfns.c	1997/04/06 12:13:44	1.1.1.1
+++ mule-wnnfns.c	1997/04/15 22:01:47
@@ -317,8 +317,6 @@
 
 /* Lisp functions definition */
 
-
-
 DEFUN ("wnn-server-open", Fwnn_open, 2, 2, 0, /*
 Connect to jserver of host HNAME, make an environment with
 login name LNAME in the server.
@@ -358,12 +356,21 @@
       strncpy (hostname, XSTRING (hname)->_data, 32);
     }
   CHECK_STRING (lname);
+  /* 97/4/16 jhod@po.iijnet.or.jp
+   * libwnn uses SIGALRM, so we need to stop and start interrupts.
+   */
+  stop_interrupts();
   if (!(wnnfns_buf[snum] = jl_open_lang (envname, hostname, langname,
 					 0, 0, 0, EGG_TIMEOUT)))
     {
+      start_interrupts();
+      return Qnil;
+    }
+  if (!jl_isconnect (wnnfns_buf[snum]))
+    {
+      start_interrupts();
       return Qnil;
     }
-  if (!jl_isconnect (wnnfns_buf[snum])) return Qnil;
   wnnfns_env_norm[snum] = jl_env_get (wnnfns_buf[snum]);
 /*  if (Vwnnenv_sticky == Qt) jl_env_sticky_e (wnnfns_env_norm[snum]);
     else jl_env_un_sticky_e (wnnfns_env_norm[snum]);*/
@@ -371,10 +378,12 @@
   if (!(wnnfns_env_rev[snum] = jl_connect_lang (envname, hostname, langname,
 						0, 0, 0, EGG_TIMEOUT)))
     {
+      start_interrupts();
       return Qnil;
     }
 /*  if (Vwnnenv_sticky == Qt) jl_env_sticky_e (wnnfns_env_rev[snum]);
     else jl_env_un_sticky_e (wnnfns_env_rev[snum]);*/
+  start_interrupts();
   return Qt;
 }
 

--Multipart_Wed_Apr_16_11:23:46_1997-1--

