]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Bug 2395: FTP errors not displayed
authorAmos Jeffries <squid3@treenet.co.nz>
Tue, 22 Dec 2009 01:52:19 +0000 (14:52 +1300)
committerAmos Jeffries <squid3@treenet.co.nz>
Tue, 22 Dec 2009 01:52:19 +0000 (14:52 +1300)
* Fix PUT and other errors hanging
* Fix assertion "entry->store_status == STORE_PENDING" caused by FTP
* Several variable-shadowing cases resolved for the fix.

src/ftp.cc

index 3545ee6b264ce7f7b2996751e8338c17feb0e72c..986dc6c9403b97a09fa71760cbf8094fe88a6163 100644 (file)
@@ -3032,10 +3032,11 @@ FtpStateData::failed(err_type error, int xerrno)
 void
 FtpStateData::failedErrorMessage(err_type error, int xerrno)
 {
-    ErrorState *err;
+    ErrorState *ftperr;
     const char *command, *reply;
+
     /* Translate FTP errors into HTTP errors */
-    err = NULL;
+    ftperr = NULL;
 
     switch (error) {
 
@@ -3049,12 +3050,12 @@ FtpStateData::failedErrorMessage(err_type error, int xerrno)
 
             if (ctrl.replycode > 500)
                 if (password_url)
-                    err = errorCon(ERR_FTP_FORBIDDEN, HTTP_FORBIDDEN, fwd->request);
+                    ftperr = errorCon(ERR_FTP_FORBIDDEN, HTTP_FORBIDDEN, fwd->request);
                 else
-                    err = errorCon(ERR_FTP_FORBIDDEN, HTTP_UNAUTHORIZED, fwd->request);
+                    ftperr = errorCon(ERR_FTP_FORBIDDEN, HTTP_UNAUTHORIZED, fwd->request);
 
             else if (ctrl.replycode == 421)
-                err = errorCon(ERR_FTP_UNAVAILABLE, HTTP_SERVICE_UNAVAILABLE, fwd->request);
+                ftperr = errorCon(ERR_FTP_UNAVAILABLE, HTTP_SERVICE_UNAVAILABLE, fwd->request);
 
             break;
 
@@ -3062,7 +3063,7 @@ FtpStateData::failedErrorMessage(err_type error, int xerrno)
 
         case SENT_RETR:
             if (ctrl.replycode == 550)
-                err = errorCon(ERR_FTP_NOT_FOUND, HTTP_NOT_FOUND, fwd->request);
+                ftperr = errorCon(ERR_FTP_NOT_FOUND, HTTP_NOT_FOUND, fwd->request);
 
             break;
 
@@ -3073,20 +3074,20 @@ FtpStateData::failedErrorMessage(err_type error, int xerrno)
         break;
 
     case ERR_READ_TIMEOUT:
-        err = errorCon(error, HTTP_GATEWAY_TIMEOUT, fwd->request);
+        ftperr = errorCon(error, HTTP_GATEWAY_TIMEOUT, fwd->request);
         break;
 
     default:
-        err = errorCon(error, HTTP_BAD_GATEWAY, fwd->request);
+        ftperr = errorCon(error, HTTP_BAD_GATEWAY, fwd->request);
         break;
     }
 
-    if (err == NULL)
-        err = errorCon(ERR_FTP_FAILURE, HTTP_BAD_GATEWAY, fwd->request);
+    if (ftperr == NULL)
+        ftperr = errorCon(ERR_FTP_FAILURE, HTTP_BAD_GATEWAY, fwd->request);
 
-    err->xerrno = xerrno;
+    ftperr->xerrno = xerrno;
 
-    err->ftp.server_msg = ctrl.message;
+    ftperr->ftp.server_msg = ctrl.message;
 
     ctrl.message = NULL;
 
@@ -3104,12 +3105,13 @@ FtpStateData::failedErrorMessage(err_type error, int xerrno)
         reply = ctrl.last_reply;
 
     if (command)
-        err->ftp.request = xstrdup(command);
+        ftperr->ftp.request = xstrdup(command);
 
     if (reply)
-        err->ftp.reply = xstrdup(reply);
+        ftperr->ftp.reply = xstrdup(reply);
 
-    fwd->fail(err);
+    entry->replaceHttpReply( ftperr->BuildHttpReply() );
+    errorStateFree(ftperr);
 }
 
 static void
@@ -3150,7 +3152,8 @@ ftpSendReply(FtpStateData * ftpState)
     else
         err->ftp.reply = xstrdup("");
 
-    errorAppendEntry(ftpState->entry, err);
+    ftpState->entry->replaceHttpReply( err->BuildHttpReply() );
+    errorStateFree(err);
 
     ftpSendQuit(ftpState);
 }