bin/72649: ftpd process can hang with high cpu load

Oleg Koreshkov okor at NONEXISTENT.zone.salut.ru
Wed Oct 13 10:40:25 PDT 2004


>Number:         72649
>Category:       bin
>Synopsis:       ftpd process can hang with high cpu load
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Wed Oct 13 17:40:24 GMT 2004
>Closed-Date:
>Last-Modified:
>Originator:     Oleg Koreshkov (okor (AT) zone.salut.ru)
>Release:        FreeBSD 4.10-RELEASE-p2 i386 (CURRENT has the same bug)
>Organization:
none
>Environment:
FreeBSD 4.10
>Description:
        ftpd process can consume 100% CPU doing nothing, looping endless loop,
        if transferd file was overwritten during transfer.
        If client of this session hangs, this ftpd process can live quite a
        long time (2 hours or even more).
>How-To-Repeat:
        Start transfer (TYPE I) of big file or delay transfer by ipfw pipe.
        In another ftp session overwrite this file with smaller size (size must be > 0).
        First ftpd process gets in to endless loop.
>Fix:
--- ftpd.c
+++ ftpd.c
@@ -2034,6 +2034,22 @@
 
 					goto data_err;
 				}
+
+				/*
+				 * sendfile(2) can return zero bytes written
+				 * (cnt == 0), without indicating error,
+				 * when file was truncated (by another process)
+				 * during transfer.
+				 * We consider this case as temporary error,
+				 * however it possible to treat it
+				 * as successful transfer completion.
+				 */
+				if (cnt == 0) {
+					transflag = 0;
+					reply(450, "File was overwritten "
+					    "during transfer.");
+					return (-1);
+				}
 			}
 
 			transflag = 0;
>Release-Note:
>Audit-Trail:
>Unformatted:
         


More information about the freebsd-bugs mailing list