[mew-win32 4463] Re: MasterPW に C-g 連打 で固まる

Hideyuki SHIRAI (白井秀行) <[email protected]>
Newsgroups gmane.mail.mew.windows
Organization Resident at Meadowy farm.
Message-ID <[email protected]>
白井です。

From: Kazu Yamamoto (山本和彦) <[email protected]> さん曰く
Subject: [mew-win32 4462] Re: MasterPW に C-g 連打で固まる
Message-ID: <[email protected]>
Date: Mon, 07 Jan 2008 12:19:36 +0900 (JST)

> > まず、 .emacs 中に以下の 2行がある場合のみ発生する様です。
> >
> > (setq visible-bell t)
> > (setq mw32-visible-bell-type 'x)  ;; X-Window 版 Emacs 風の描画設定
> >
> > 両方コメントアウトした場合も、2行目だけコメントアウトした場合も発生しな
> > い様です。
>
> この件は、Meadow のバグということで、忘れることにします。

これ、Meadow 固有の現象だとするとプログラムを start-process して
そのプロセスが生きている間に、関連付けられているバッファ(今回は
with-temp-buffer)が消えちゃったとき、なぜだか CPU 100% になっちゃ
うことがよくある。。。という話なのですが、いろいろと実験したので
話の蒸し返し。

試したところ、

(setq visible-bell t)

で、C-g 連打だと Solaris や Zarus で使っている Emacs CVS Head で
も Emacs が暴走することがありました。頻度は Meadow で実験したと
きよりもめちゃくちゃ低いですが、症状は同じものだと思います。

# いままで visible-bell => nil で生活してきたし、こういう状況で
# C-g 連打って、まずやらないので、master passwd 入力以外ではどう
# なるのか?などは判りません。

でもって、visible-bell の処理は xterm.c, (Meadowの)mw32term.c,
macterm.c で全然違う処理をしているので、かずさんが使っている
Mac では発生しないとか。。。

この現象が visible-bell が t というのがトリガになっているかどう
かは今一不明ですが、以下のパッチでとりあえずは大丈夫みたいです。

(1) mew-rendezvous() で待っているとき C-g で抜けた場合の対処
(2) mew-passwd-sentinel() で、mew-passwd-rendezvous は
    buffer-local じゃないので、set-buffer() をやめた。
   => C-g 連打で結構エラーになる。with-temp-buffer を抜けてから
      sentinel が来るのかな?
(3) (ほとんど)Meadow のために process を kill するようにした。

です。理由ははっきりしないのですが、ぼくが実験した限りでは大丈夫
そうなので、追試募集です。

--
白井秀行 (mailto:[email protected])
masterpw.diff (text/plain, 2.5 KB)
Index: mew-func.el
===================================================================
RCS file: /cvsmew/mew/mew-func.el,v
retrieving revision 1.190
diff -u -r1.190 mew-func.el
--- mew-func.el	7 Jan 2008 08:19:39 -0000	1.190
+++ mew-func.el	11 Jan 2008 05:27:30 -0000
@@ -1529,14 +1529,17 @@
 (defun mew-redraw (&optional time)
   (sit-for (or time 0)))
 
-(defmacro mew-rendezvous (who)
+(defmacro mew-rendezvous (who &optional iquit)
   ;; Wait for the termination of WHO.
   ;; Emacs does not provide synchronize mechanism with
   ;; an asynchronous process. So, take this way. 
-  `(while ,who
-     (sit-for 0.1)
-     ;; accept-process-output or sleep-for is not enough
-     (discard-input)))
+  `(let ((inhibit-quit ,iquit))
+     (while ,who
+       (sit-for 0.1)
+       ;; accept-process-output or sleep-for is not enough
+       (discard-input)
+       (when (and inhibit-quit quit-flag)
+	 (setq ,who nil)))))
 
 (defun mew-let-user-read ()
   (sit-for 1.5))
Index: mew-passwd.el
===================================================================
RCS file: /cvsmew/mew/mew-passwd.el,v
retrieving revision 1.12
diff -u -r1.12 mew-passwd.el
--- mew-passwd.el	25 Jul 2007 06:06:59 -0000	1.12
+++ mew-passwd.el	11 Jan 2008 05:27:30 -0000
@@ -170,7 +170,9 @@
 	      (set-process-filter   pro 'mew-passwd-filter)
 	      (set-process-sentinel pro 'mew-passwd-sentinel)
 	      (setq mew-passwd-rendezvous t)
-	      (mew-rendezvous mew-passwd-rendezvous)
+	      (mew-rendezvous mew-passwd-rendezvous 'inhibit-quit)
+	      (if (and (processp pro) (memq pro '(run stop)))
+		  (kill-process pro))
 	      (when mew-passwd-master
 		(let ((coding-system-for-read 'undecided))
 		  (insert-file-contents tfile))
@@ -205,7 +207,9 @@
 	      (set-process-filter   pro 'mew-passwd-filter)
 	      (set-process-sentinel pro 'mew-passwd-sentinel)
 	      (setq mew-passwd-rendezvous t)
-	      (mew-rendezvous mew-passwd-rendezvous)
+	      (mew-rendezvous mew-passwd-rendezvous 'inhibit-quit)
+	      (if (and (processp pro) (memq pro '(run stop)))
+		  (kill-process pro))
 	      (if (file-exists-p file) (throw 'loop nil))
 	      (setq i (1+ i)))
 	    (message "Master password is wrong! Passwords not saved")
@@ -242,9 +246,7 @@
 	(setq mew-passwd-rendezvous nil))))))
 
 (defun mew-passwd-sentinel (process event)
-  (save-excursion
-    (set-buffer (process-buffer process))
-    (setq mew-passwd-rendezvous nil)))
+  (setq mew-passwd-rendezvous nil))
 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;;;
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.