From owner-freebsd-current Sun Mar 3 5:49:52 2002 Delivered-To: freebsd-current@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 821) id DC45F37B400; Sun, 3 Mar 2002 05:49:48 -0800 (PST) Date: Sun, 3 Mar 2002 05:49:48 -0800 From: John To: Current List Subject: ftpd ESTALE patch Message-ID: <20020303054948.A29473@FreeBSD.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG Hi, I've had the following patch installed for some time now. Basically, we ran into a situation where files being generated/stored to a fileserver from client A and then handed by out by ftp from a different client host was failing. The following patch handles the recoverable ESTALE situation. Trace/debug output is done when the logging level is 2 or more as is done elsewhere. It is also worth noting that ESTALE is not documented as a valid errno return from open(). Thanks, John The patch can also be found online at: http://people.freebsd.org/~jwd/ftpd.estale.patch Index: ftpd.c =================================================================== RCS file: /home/ncvs/src/libexec/ftpd/ftpd.c,v retrieving revision 1.99 diff -u -r1.99 ftpd.c --- ftpd.c 25 Feb 2002 16:39:34 -0000 1.99 +++ ftpd.c 3 Mar 2002 13:25:00 -0000 @@ -1478,7 +1478,15 @@ time_t start; if (cmd == 0) { - fin = fopen(name, "r"), closefunc = fclose; + int try = 0; + while ((fin = fopen(name,"r")) == NULL && errno == ESTALE && try < 3 ) { + sleep(++try); + if (logging > 1) + syslog(LOG_INFO,"get fopen(\"%s\"): %m: attempting retry",name); + } + if (fin == NULL && logging > 1) + syslog(LOG_INFO,"get fopen(\"%s\"): %m",name); + closefunc = fclose; st.st_size = 0; } else { char line[BUFSIZ]; To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message