Fix reply generation for data transfer errors and aborts.

This commit is contained in:
sperber 2003-02-27 09:01:45 +00:00
parent 7f81f8bed9
commit ee5aba4cf5
1 changed files with 10 additions and 8 deletions

View File

@ -884,7 +884,6 @@
(define (handle-port stuff) (define (handle-port stuff)
(log-command (syslog-level info) "PORT" stuff) (log-command (syslog-level info) "PORT" stuff)
(ensure-authenticated-login) (ensure-authenticated-login)
(maybe-close-data-connection)
(call-with-values (call-with-values
(lambda () (ftpd-parse-port-arg stuff)) (lambda () (ftpd-parse-port-arg stuff))
(lambda (address port) (lambda (address port)
@ -915,7 +914,6 @@
(define (handle-pasv stuff) (define (handle-pasv stuff)
(log-command (syslog-level info) "PASV") (log-command (syslog-level info) "PASV")
(ensure-authenticated-login) (ensure-authenticated-login)
(maybe-close-data-connection)
(let ((socket (create-socket protocol-family/internet (let ((socket (create-socket protocol-family/internet
socket-type/stream))) socket-type/stream)))
@ -1165,9 +1163,15 @@
(log (syslog-level debug) "authenticated login ensured"))) (log (syslog-level debug) "authenticated login ensured")))
(define (with-data-connection thunk) (define (with-data-connection thunk)
(dynamic-wind ensure-data-connection (ensure-data-connection)
thunk (with-fatal-error-handler*
maybe-close-data-connection)) (lambda (condition more)
(maybe-close-data-connection))
(lambda ()
(thunk)
(maybe-close-data-connection)
(log (syslog-level debug) "closing data connection (226)")
(register-reply! 226 "Closing data connection."))))
(define *window-size* 4096) (define *window-size* 4096)
@ -1202,8 +1206,6 @@
(close-socket (the-session-data-socket))) (close-socket (the-session-data-socket)))
(if (the-session-passive-socket) (if (the-session-passive-socket)
(close-socket (the-session-passive-socket))) (close-socket (the-session-passive-socket)))
(log (syslog-level debug) "closing data connection (226)")
(register-reply! 226 "Closing data connection.")
(set-the-session-data-socket! #f) (set-the-session-data-socket! #f)
(set-the-session-passive-socket! #f)) (set-the-session-passive-socket! #f))
@ -1307,7 +1309,7 @@
(define (register-reply! code . messages) (define (register-reply! code . messages)
(if (the-session-reply-code) (if (the-session-reply-code)
(apply error "tried to register more than one reply" code messages) (apply error "tried to register more than one reply" code messages (the-session-replies))
(apply replace-reply! code messages))) (apply replace-reply! code messages)))
(define (replace-reply! code . messages) (define (replace-reply! code . messages)