]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Remove redundant FTP/Gopher checks
authorAmos Jeffries <squid3@treenet.co.nz>
Sat, 12 Mar 2011 03:34:48 +0000 (16:34 +1300)
committerAmos Jeffries <squid3@treenet.co.nz>
Sat, 12 Mar 2011 03:34:48 +0000 (16:34 +1300)
Identified by ICC.

src/ftp.cc
src/gopher.cc

index 8490922705c2d23d11acb4b113666fdfde41fdab..5858e024d3a161ea79c03a9d9c6888c54f663a2e 100644 (file)
@@ -1270,7 +1270,7 @@ FtpStateData::dataRead(const CommIoCbParams &io)
         IOStats.Ftp.read_hist[bin]++;
     }
 
-    if (io.flag != COMM_OK || io.size < 0) {
+    if (io.flag != COMM_OK) {
         debugs(50, ignoreErrno(io.xerrno) ? 3 : DBG_IMPORTANT,
                "ftpDataRead: read error: " << xstrerr(io.xerrno));
 
@@ -1769,7 +1769,7 @@ void FtpStateData::ftpReadControlReply(const CommIoCbParams &io)
         fd_bytes(io.fd, io.size, FD_READ);
     }
 
-    if (io.flag != COMM_OK || io.size < 0) {
+    if (io.flag != COMM_OK) {
         debugs(50, ignoreErrno(io.xerrno) ? 3 : DBG_IMPORTANT,
                "ftpReadControlReply: read error: " << xstrerr(io.xerrno));
 
@@ -1778,9 +1778,7 @@ void FtpStateData::ftpReadControlReply(const CommIoCbParams &io)
         } else {
             failed(ERR_READ_ERROR, io.xerrno);
             /* failed closes ctrl.fd and frees ftpState */
-            return;
         }
-
         return;
     }
 
index 5204526241a17c369b51efb05ab738ea2002287c..fa78bf26e6478302a92c7a37fbbf19deaf997361 100644 (file)
@@ -776,7 +776,6 @@ gopherReadReply(int fd, char *buf, size_t len, comm_err_t flag, int xerrno, void
     int clen;
     int bin;
     size_t read_sz = BUFSIZ;
-    int do_next_read = 0;
 #if USE_DELAY_POOLS
     DelayId delayId = entry->mem_obj->mostBytesAllowed();
 #endif
@@ -826,26 +825,23 @@ gopherReadReply(int fd, char *buf, size_t len, comm_err_t flag, int xerrno, void
             req->hier.bodyBytesRead = 0;
 
         req->hier.bodyBytesRead += len;
-
     }
 
-    if (flag != COMM_OK || len < 0) {
+    if (flag != COMM_OK) {
         debugs(50, 1, "gopherReadReply: error reading: " << xstrerror());
 
         if (ignoreErrno(errno)) {
-            do_next_read = 1;
+            comm_read(fd, buf, read_sz, gopherReadReply, gopherState);
         } else {
             ErrorState *err;
             err = errorCon(ERR_READ_ERROR, HTTP_INTERNAL_SERVER_ERROR, gopherState->fwd->request);
             err->xerrno = errno;
             gopherState->fwd->fail(err);
             comm_close(fd);
-            do_next_read = 0;
         }
     } else if (len == 0 && entry->isEmpty()) {
         gopherState->fwd->fail(errorCon(ERR_ZERO_SIZE_OBJECT, HTTP_SERVICE_UNAVAILABLE, gopherState->fwd->request));
         comm_close(fd);
-        do_next_read = 0;
     } else if (len == 0) {
         /* Connection closed; retrieval done. */
         /* flush the rest of data in temp buf if there is one. */
@@ -854,28 +850,17 @@ gopherReadReply(int fd, char *buf, size_t len, comm_err_t flag, int xerrno, void
             gopherEndHTML(gopherState);
 
         entry->timestampsSet();
-
         entry->flush();
-
         gopherState->fwd->complete();
-
         comm_close(fd);
-
-        do_next_read = 0;
     } else {
         if (gopherState->conversion != gopher_ds::NORMAL) {
             gopherToHTML(gopherState, buf, len);
         } else {
             entry->append(buf, len);
         }
-
-        do_next_read = 1;
-    }
-
-    if (do_next_read)
         comm_read(fd, buf, read_sz, gopherReadReply, gopherState);
-
-    return;
+    }
 }
 
 /**