[comp.bugs.4bsd] 4.2BSD ftp Bug

steve@gec-mi-at.co.uk (Steve Lademann) (07/08/87)

Having spent the last couple of months upgrading two 11/750s to 4.3BSD, I
have encountered a few minor bugs which I have fixes for. Here's one in ftp.

Problem:	When transmitting files to a remote system with a System V.0
		machine equipped with an Ethernet and similar vintage 
		Berkeley networking software, there is a problem with
		ftp which exhibits itself by occasionally losing the final
		block. This is due to a race condition within the System V.0
		code. However, I haven't got the source for the System V
		end, so I have had to apply the fixes to the BSD end. Now, I
		know this isn't a sanitary way to fix problems, but I haven't
		got much choice! The fix below makes it work, empirically
		speaking, so if you're in a similar position and you are
		looking for a fix at *any* price, apply the following patches.
		If you know of a more sanitary means of solving the same
		problem, please let me know, bearing in mind that I have
		no access to the System V stuff (some machines have it burned
		in ROM!). Files affected are /usr/src/ucb/ftp/ftp.c and
		/usr/src/etc/ftpd/ftpd.c

Fix:
*** ftp.c.old	Wed Jul  1 13:44:55 1987
--- ftp.c	Wed Jul  8 15:53:14 1987
***************
*** 517,522 ****
--- 517,528 ----
  	(void) gettimeofday(&stop, (struct timezone *)0);
  	if (closefunc != NULL)
  		(*closefunc)(fin);
+ 	/*
+ 	 * Horrendous kludge to make it work to System V.0 - really
+ 	 * must find out why this doesn't work steve@gec-mi-at.co.uk
+ 	 */
+ 	(void) fflush(dout);
+ 	sleep(2);
  	(void) fclose(dout);
  	(void) getreply(0);
  	(void) signal(SIGINT, oldintr);

*** ftpd.c.old	Thu Apr 30 18:05:59 1987
--- ftpd.c	Wed Jul  8 14:37:31 1987
***************
*** 307,312 ****
--- 307,319 ----
  	else if (tmp == 0) {
  		reply(226, "Transfer complete.");
  	}
+ /*
+  * Next two lines are a horrendous kludge to make System V.0 TCP/IP from an
+  * IBM PC work - really ought to fix bug properly steve@gec-mi-at.co.uk
+  */
+ 	(void) fflush(dout);
+ 	sleep(3);
+ 
  	(void) fclose(dout);
  	data = -1;
  	pdata = -1;

|Steve Lademann		|Phone: 44 727 59292 x326		|
|Marconi Instruments Ltd|UUCP : ...mcvax!ukc!hrc63!miduet!steve	|
|St. Albans    AL4 0JN	|NRS  : steve@uk.co.gec-mi-at		|
|Herts.   UK		|	"disclaimers.all"