[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Bug that needs fixing
From: |
Stefan Monnier |
Subject: |
Re: Bug that needs fixing |
Date: |
Thu, 21 Jul 2005 16:41:01 -0400 |
User-agent: |
Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (gnu/linux) |
SM> I've finally had time to take a look at it on my Mac OS X system and I can
SM> indeed reproduce it. The patch below seems to fix it, but it's maybe a bit
SM> naive, I don't know.
SM> Does someone see something wrong with such a patch?
>>
>> It does solve the problem, but I have some doubts: What happens when
>> it was a real error. Maybe at least some IPV6 check should be in, e.g.
>> by including a colon in the r.e.
> This case the patch doesn't work, indeed.
> First of all, I had to adapt the regexp of Stefan a little bit. My ftp
> client responds this:
> magdalene:~> ftp 192.168.0.9
> ftp: connect: No route to host
> When I apply the (modified) patch from Stefan, ange-ftp is locked in
> `ange-ftp-wait-not-busy', as suspected.
>> Even better would be to check that it is followed by 'Trying', but the
>> current implementation of ange-ftp doesn't allow for multi-line
>> regexps AFAIK.
> One could play with `ange-ftp-multi-msgs'. Unfortunately, I cannot
> test this due to my ftp client restrictions ...
The problem is that none of the existing mechanisms in ange-ftp handle the
situation where a message can be an error or not depending on
subsequent messages. The ange-ftp-multi-msgs is only useful for messages
which always span several lines.
Can someone test(&fix) the patch below? Also could someone try and convince
himself that it is harmless?
Stefan
--- ange-ftp.el 04 jui 2005 14:42:05 -0400 1.67
+++ ange-ftp.el 21 jui 2005 16:40:49 -0400
@@ -743,6 +743,21 @@
:group 'ange-ftp
:type 'regexp)
+(defcustom ange-ftp-potential-error-msgs
+ ;; On Mac OS X we sometimes get things like:
+ ;;
+ ;; ftp> open ftp.nluug.nl
+ ;; Trying 2001:610:1:80aa:192:87:102:36...
+ ;; ftp: connect to address 2001:610:1:80aa:192:87:102:36: No route to
host
+ ;; Trying 192.87.102.36...
+ ;; Connected to ftp.nluug.nl.
+ "^ftp: connect to address .*: No route to host"
+ "*Regular expression matching ftp messages that can indicate serious errors.
+These mean that something went wrong, but they may be followed by more
+messages indicating that the error was somehow corrected."
+ :group 'ange-ftp
+ :type 'regexp)
+
(defcustom ange-ftp-gateway-fatal-msgs
"No route to host\\|Connection closed\\|No such host\\|Login incorrect"
"*Regular expression matching login failure messages from rlogin/telnet."
@@ -1071,6 +1086,7 @@
(defvar ange-ftp-xfer-size nil)
(defvar ange-ftp-process-string nil)
(defvar ange-ftp-process-result-line nil)
+(defvar ange-ftp-pending-error-line nil)
(defvar ange-ftp-process-busy nil)
(defvar ange-ftp-process-result nil)
(defvar ange-ftp-process-multi-skip nil)
@@ -1544,6 +1560,7 @@
((string-match ange-ftp-good-msgs line)
(setq ange-ftp-process-busy nil
ange-ftp-process-result t
+ ange-ftp-pending-error-line nil
ange-ftp-process-result-line line))
;; Check this before checking for errors.
;; Otherwise the last line of these three seems to be an error:
@@ -1558,6 +1575,12 @@
ange-ftp-process-result-line line))
(ange-ftp-process-multi-skip
t)
+ ((string-match ange-ftp-potential-error-msgs line)
+ ;; This looks like an error, but we have to keep reading the output
+ ;; to see if it was fixed or not. E.g. it may indicate that IPv6
+ ;; failed, but maybe a subsequent IPv4 fallback succeeded.
+ (set (make-local-variable 'ange-ftp-pending-error-line) line)
+ t)
(t
(setq ange-ftp-process-busy nil
ange-ftp-process-result-line line))))
@@ -1651,12 +1674,20 @@
(string-match "\n" ange-ftp-process-string))
(let ((line (substring ange-ftp-process-string
0
- (match-beginning 0))))
+ (match-beginning 0)))
+ (seen-prompt nil))
(setq ange-ftp-process-string (substring
ange-ftp-process-string
(match-end 0)))
(while (string-match "^ftp> *" line)
+ (setq seen-prompt t)
(setq line (substring line (match-end 0))))
- (ange-ftp-process-handle-line line proc)))
+ (if (and seen-prompt ange-ftp-pending-error-line)
+ ;; If we've seen a potential error message and it
+ ;; hasn't been cancelled by a good message before
+ ;; seeing a propt, then the error was real.
+ (setq ange-ftp-process-busy nil
+ ange-ftp-process-result-line
ange-ftp-pending-error-line)
+ (ange-ftp-process-handle-line line proc))))
;; has the ftp client finished? if so then do some clean-up
;; actions.
@@ -1988,7 +2019,7 @@
(make-local-variable 'comint-password-prompt-regexp)
;; This is a regexp that can't match anything.
;; ange-ftp has its own ways of handling passwords.
- (setq comint-password-prompt-regexp "^a\\'z")
+ (setq comint-password-prompt-regexp "\\`a\\`")
(make-local-variable 'paragraph-start)
(setq paragraph-start comint-prompt-regexp)
(run-mode-hooks 'internal-ange-ftp-mode-hook))
@@ -4543,9 +4574,9 @@
(setq ange-ftp-ls-cache-file nil) ;Stop confusing Dired.
0)
-;;; This is turned off because it has nothing properly to do
-;;; with dired. It could be reasonable to adapt this to
-;;; replace ange-ftp-copy-file.
+;; This is turned off because it has nothing properly to do
+;; with dired. It could be reasonable to adapt this to
+;; replace ange-ftp-copy-file.
;;;;; ------------------------------------------------------------
;;;;; Noddy support for async copy-file within dired.