From c60b51c6327e99071c328b3873faebd109a4aa76 Mon Sep 17 00:00:00 2001 From: "Taylor R. Campbell" Date: Sun, 25 Dec 2005 17:43:52 +0000 Subject: [PATCH] Signal a recognizable NNTP EOF error instead of a simple error if the the server silently closes the connection and NNTP-READ-LINE receives an EOF, so that NNTP-PROTECT can handle the condition and reopen the connection in this event, when before it would just signal an Edwin Edwin error. The response field of NNTP errors can now be either a string or an EOF object. --- v7/src/edwin/nntp.scm | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/v7/src/edwin/nntp.scm b/v7/src/edwin/nntp.scm index 26d3d8f62..9fed9b147 100644 --- a/v7/src/edwin/nntp.scm +++ b/v7/src/edwin/nntp.scm @@ -1,6 +1,6 @@ #| -*-Scheme-*- -$Id: nntp.scm,v 1.30 2005/12/25 05:56:58 riastradh Exp $ +$Id: nntp.scm,v 1.31 2005/12/25 17:43:52 riastradh Exp $ Copyright 1995,1996,1997,1998,1999,2003 Massachusetts Institute of Technology Copyright 2004,2005 Massachusetts Institute of Technology @@ -341,7 +341,11 @@ USA. '(RESPONSE) (lambda (condition port) (write-string "NNTP error: " port) - (write-string (nntp-error/response condition) port)))) + (let ((response (nntp-error/response condition))) + (write-string (if (eof-object? response) + "connection lost" + response) + port))))) (define nntp-error/response (condition-accessor condition-type:nntp-error 'RESPONSE)) @@ -373,9 +377,11 @@ USA. (lambda (condition) ;; If the server closed the connection, try again. This ;; should automatically re-open the connection. - (case (nntp-response-number (nntp-error/response condition)) - ((205 503) - (within-continuation k try)))) + (let ((response (nntp-error/response condition))) + (if (or (eof-object? response) + (memv (nntp-response-number response) + '(205 503))) + (within-continuation k try)))) try))))) ;;;; NNTP I/O @@ -405,7 +411,7 @@ USA. (define (nntp-read-line connection) (let ((line (input-port/read-line (nntp-connection:port connection)))) (if (eof-object? line) - (error "Premature EOF from NNTP connection:" connection)) + (nntp-error line)) line)) (define (nntp-response-number line) -- 2.25.1