From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Lennart Borgman Newsgroups: gmane.emacs.devel Subject: Re: Ftp freezes on w32 Date: Sun, 12 Nov 2006 13:13:11 +0100 Message-ID: <45570FD7.7020200@student.lu.se> References: <454C77D4.2090609@student.lu.se> <454D305C.7080600@student.lu.se> <454DDE39.6060001@student.lu.se> <454FDDF1.7010709@student.lu.se> <45504299.3040701@student.lu.se> <4550A650.7000808@student.lu.se> <50172.128.165.123.18.1162918815.squirrel@webmail.lanl.gov> <4550D453.6080809@student.lu.se> <45510910.2030907@student.lu.se> <4551854D.4030005@student.lu.se> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------030008040500040303060809" X-Trace: sea.gmane.org 1163333624 10311 80.91.229.2 (12 Nov 2006 12:13:44 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Sun, 12 Nov 2006 12:13:44 +0000 (UTC) Cc: lekktu@gmail.com, emacs-devel@gnu.org, jasonr@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sun Nov 12 13:13:42 2006 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1GjEDT-0007K0-Uv for ged-emacs-devel@m.gmane.org; Sun, 12 Nov 2006 13:13:40 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1GjEDT-0001I4-7z for ged-emacs-devel@m.gmane.org; Sun, 12 Nov 2006 07:13:39 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1GjEDE-0001He-2L for emacs-devel@gnu.org; Sun, 12 Nov 2006 07:13:24 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1GjEDC-0001HD-Vp for emacs-devel@gnu.org; Sun, 12 Nov 2006 07:13:23 -0500 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1GjEDC-0001H0-QZ for emacs-devel@gnu.org; Sun, 12 Nov 2006 07:13:22 -0500 Original-Received: from [80.76.149.213] (helo=ch-smtp02.sth.basefarm.net) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA:32) (Exim 4.52) id 1GjED6-0004Ub-5G; Sun, 12 Nov 2006 07:13:16 -0500 Original-Received: from [83.254.145.24] (port=64757 helo=[192.168.123.121]) by ch-smtp02.sth.basefarm.net with esmtp (Exim 4.63) (envelope-from ) id 1GjED2-0002Pf-8d; Sun, 12 Nov 2006 13:13:13 +0100 User-Agent: Thunderbird 1.5.0.8 (Windows/20061025) Original-To: Eli Zaretskii In-Reply-To: X-Scan-Result: No virus found in message 1GjED2-0002Pf-8d. X-Scan-Signature: ch-smtp02.sth.basefarm.net 1GjED2-0002Pf-8d 28be33567c4ff97207ca9191964b5880 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:62109 Archived-At: This is a multi-part message in MIME format. --------------030008040500040303060809 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Eli Zaretskii wrote: >> Date: Wed, 08 Nov 2006 08:20:45 +0100 >> From: Lennart Borgman >> CC: lekktu@gmail.com, jasonr@gnu.org, emacs-devel@gnu.org >> >>> I think it's not a good idea to have changes in your version that are >>> not in the official code base. >>> >>> >> So what is your suggestion? >> > > Either convince us to install your changes in the CVS, or wait with > the change until after the release and get it into CVS then. > Ok. My main argument is that I can find no way to get ange-ftp to work on w2k (at least on my pc) without something like this patch. The patch is also quite general in its structure so it can perhaps be used for other problems with the ftp process. And it is quite small. In the attached patch I did not remove my trace functions. They should of course not be there in the final version. --------------030008040500040303060809 Content-Type: text/plain; name="ange-ftp-nulls.diff" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="ange-ftp-nulls.diff" Index: ange-ftp.el =================================================================== RCS file: /cvsroot/emacs/emacs/lisp/net/ange-ftp.el,v retrieving revision 1.80 diff -u -r1.80 ange-ftp.el --- ange-ftp.el 6 Feb 2006 11:33:04 -0000 1.80 +++ ange-ftp.el 11 Nov 2006 14:22:59 -0000 @@ -1641,10 +1641,43 @@ ;; Build up a complete line of output from the ftp PROCESS and pass it ;; on to ange-ftp-process-handle-line to deal with. +(defvar ange-ftp-proc-trace nil) +(defvar ange-ftp-proc-trace-on nil) +;;(setq ange-ftp-proc-trace-on t) <- +(defun ange-ftp-add-to-proc-trace(str) + (when ange-ftp-proc-trace-on + (setq ange-ftp-proc-trace (cons str ange-ftp-proc-trace)))) +(defun ange-ftp-show-proc-trace() + (interactive) + (let ((buf (get-buffer-create "ange-ftp-proc-trace"))) + (with-current-buffer buf + (erase-buffer) + (insert (format "%s" (apply 'concat ange-ftp-proc-trace)))) + (switch-to-buffer-other-window buf))) + (defun ange-ftp-process-filter (proc str) ;; Eliminate nulls. - (while (string-match "\000+" str) - (setq str (replace-match "" nil nil str))) + ;; + ;; Also check if the ftp process seems ok. If it is not ok throw + ;; `ange-ftp-proc-defunct' which will be caught by + ;; `ange-ftp-raw-send' that will then restart the ftp process. + ;; + ;; On w32 when the ftp program from gnu + ;; (ftp://ftp.gnu.org/old-gnu/emacs/windows/contrib/ftp-for-win32.zip) + ;; is used Emacs will read a string consisting of only nulls after + ;; the ftp program has timed out. The only way I have found to cure + ;; this is to delete the ftp process. + (ange-ftp-add-to-proc-trace (format "str=%s\n" str)) + (let ((str-len (length str))) + (while (string-match "\000+" str) + (setq str (replace-match "" nil nil str))) + (when (and (boundp 'ange-ftp-check-proc-ok) + ange-ftp-check-proc-ok + (cond ((eq system-type 'windows-nt) + (and + (= 0 (length str)) + (< 20 str-len))))) + (throw 'ange-ftp-proc-defunct t))) ;; see if the buffer is still around... it could have been deleted. (when (buffer-live-p (process-buffer proc)) @@ -2277,7 +2310,9 @@ (ange-ftp-this-user user) (ange-ftp-this-host host) (ange-ftp-this-msg msg) - cmd2 cmd3 host-type fix-name-func result) + cmd2 cmd3 host-type fix-name-func result + (sent-sts nil) + (sent-res nil)) (cond @@ -2365,37 +2400,55 @@ (and cmd2 (concat " " cmd2)))) ;; Actually send the resulting command. - (if (and (consp result) (null (car result))) - ;; `ange-ftp-cd' has failed, so there's no point sending `cmd'. - result - (let (afsc-result - afsc-line) - (ange-ftp-raw-send-cmd - (ange-ftp-get-process host user) - cmd - msg - (list (lambda (result line host user cmd msg cont nowait) - (or cont (setq afsc-result result - afsc-line line)) - (if result (ange-ftp-call-cont cont result line) - (ange-ftp-raw-send-cmd - (ange-ftp-get-process host user) - cmd - msg - (list (lambda (result line cont) - (or cont (setq afsc-result result - afsc-line line)) - (ange-ftp-call-cont cont result line)) - cont) - nowait))) - host user cmd msg cont nowait) - nowait) - - (if nowait - nil - (if cont - nil - (cons afsc-result afsc-line))))))) + (while (memq sent-sts '(nil tried)) + (when (eq sent-sts 'tried) + ;; Delete ftp process if send failed before, it will be + ;; restarted by `ange-ftp-get-process'. + (message "Ftp process possibly defunct, deleting it ...") + (ange-ftp-add-to-proc-trace "\n********* DEFUNCT killing ftp process\\n") + (let* ((proc (ange-ftp-get-process host user)) + (delete-exited-processes t)) + (delete-process proc))) + (if (and (consp result) (null (car result))) + ;; `ange-ftp-cd' has failed, so there's no point sending `cmd'. + (progn + (setq sent-res result) + (setq sent-sts 'failed)) + (let (afsc-result + afsc-line + (ange-ftp-check-proc-ok (not nowait))) + (catch 'ange-ftp-proc-defunct + (setq sent-sts 'tried) + ;; May throw 'ange-ftp-proc-defunct: + (ange-ftp-add-to-proc-trace (format "cmd=%s\n" cmd)) + (ange-ftp-raw-send-cmd + (ange-ftp-get-process host user) + cmd + msg + (list (lambda (result line host user cmd msg cont nowait) + (or cont (setq afsc-result result + afsc-line line)) + (if result (ange-ftp-call-cont cont result line) + (ange-ftp-raw-send-cmd + (ange-ftp-get-process host user) + cmd + msg + (list (lambda (result line cont) + (or cont (setq afsc-result result + afsc-line line)) + (ange-ftp-call-cont cont result line)) + cont) + nowait))) + host user cmd msg cont nowait) + nowait) + + (setq sent-sts 'ok) + (if nowait + (setq sent-res nil) + (if cont + (setq sent-res nil) + (setq sent-res (cons afsc-result afsc-line)))))))) + sent-res)) ;; It might be nice to message users about the host type identified, ;; but there is so much other messaging going on, it would not be --------------030008040500040303060809 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Emacs-devel mailing list Emacs-devel@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-devel --------------030008040500040303060809--