This is the mail archive of the cygwin-apps mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

setup: patch for ftp deadlock


It was a little weird working on my own code from so long ago, but...

We needed this patch on our local version of setup to fix a deadlock
between the FTP data socket and the PASV command, the RFC suggests
closing out the data socket before starting the next transaction, so
that's what this tries to do.  When read() returns EOF, we check for
the end-of-transaction status code on the command socket so that the
server closes out the socket properly before we get to the next PASV
command.

With our FTP server, the PASV command didn't work if you issue it
before reading the status from the RETR, so we waited forever for the
PASV status code which never came.

	* nio-ftp.c (read): Read RETR status code on EOF to avoid
	deadlock with PASV.

diff -U 3 -r rhsetup-src/nio-ftp.cc setup/nio-ftp.cc
--- rhsetup-src/nio-ftp.cc	2008-04-08 19:50:54.000000000 -0400
+++ setup/nio-ftp.cc	2010-03-11 23:09:42.000000000 -0500
@@ -174,7 +174,11 @@
 int
 NetIO_FTP::read (char *buf, int nbytes)
 {
+  int rv, code;
   if (!ok ())
     return 0;
-  return s->read (buf, nbytes);
+  rv = s->read (buf, nbytes);
+  if (rv == 0)
+    code = ftp_line (cmd);
+  return rv;
 }


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]