]> git.sesse.net Git - betaftpd/commitdiff
Fixed a file transfer bug, where the initial "150 Opening connection (...)" message...
authorsgunderson <sgunderson>
Tue, 9 Oct 2001 21:33:46 +0000 (21:33 +0000)
committersgunderson <sgunderson>
Tue, 9 Oct 2001 21:33:46 +0000 (21:33 +0000)
ftpd.c
ftpd.h

diff --git a/ftpd.c b/ftpd.c
index 73f1dcad7105cf5232acc6605051e0a0c12798a7..19816bfd489801da7c80087166d1563831b2ad31 100644 (file)
--- a/ftpd.c
+++ b/ftpd.c
@@ -683,12 +683,25 @@ int process_all_sendfiles(fd_set * const active_clients, const int num_ac)
                        f->sock = tempsock;
                        ioctl(f->sock, FIONBIO, &one);
                        init_file_transfer(f);
+                       
+                       flush_numeric(f->owner);
+                       if (f->owner->free_me) {
+                               destroy_conn(f->owner);
+                               continue;
+                       }
+       
 #if WANT_UPLOAD
                        if (f->upload) continue;
 #endif
                }
                if (f->state < 5) {
                        init_file_transfer(f);
+                       
+                       flush_numeric(f->owner);
+                       if (f->owner->free_me) {
+                               destroy_conn(f->owner);
+                               continue;
+                       }
 #if WANT_UPLOAD
                        if (f->upload) continue;
 #endif
@@ -1225,6 +1238,16 @@ void numeric(struct conn * const c, const int numeric, const char * const format
        va_end(args);
 }
 
+/* flush_numeric():
+ *             Actually flushes the buffer written by numeric() -- but does
+ *             NOT erase it. If an error, sets the "free_me" flag in the socket.
+ */
+void flush_numeric(struct conn * const c)
+{
+       if (send(c->sock, message_buf, strlen(message_buf), 0) == -1 && errno == EPIPE)
+               c->free_me = 1;
+}
+
 /*
  * init_file_transfer():
  *             Initiate a data connection for sending. This does not open
diff --git a/ftpd.h b/ftpd.h
index 835f4d72a0682c05d5b7086e29331ebf63ec3b81..3d11bea8841e6554fdf66004c81ec5356fda1341 100644 (file)
--- a/ftpd.h
+++ b/ftpd.h
@@ -209,6 +209,7 @@ void time_out_sockets();
 
 void remove_bytes(struct conn * const c, const int i);
 void numeric(struct conn * const c, const int numeric, const char * const format, ...);
+void flush_numeric(struct conn * const c);
 void init_file_transfer(struct ftran * const f);
 int create_server_socket();