]> git.sesse.net Git - betaftpd/commitdiff
(Hopefully) fixed a bug that prevented uploading from working properly (thanks to...
authorsgunderson <sgunderson>
Sun, 5 Nov 2000 01:48:51 +0000 (01:48 +0000)
committersgunderson <sgunderson>
Sun, 5 Nov 2000 01:48:51 +0000 (01:48 +0000)
ftpd.c
ftpd.h

diff --git a/ftpd.c b/ftpd.c
index 7f73e8951ca177e08e15bbd060c05c9e2b1ae16a..1312a85a81dc3cf27f06b1bb867d28cb0cc1a2d1 100644 (file)
--- a/ftpd.c
+++ b/ftpd.c
@@ -580,6 +580,29 @@ int process_all_clients(const fd_set * const active_clients, const int num_ac)
        return checked_through;
 }
 
+/*
+ * finish_transfer():
+ *             Send a message that the transfer is completed, write xferlog
+ *             entry (optional), and update the last_transfer record in the
+ *             file transfer object. Goes for both uploads and downloads.
+ */
+void finish_transfer(struct ftran * const f)
+{
+       numeric(f->owner, 226, "Transfer complete.");
+       time(&(f->owner->last_transfer));
+
+#if WANT_XFERLOG
+       if (!f->dir_listing) {
+               write_xferlog(f);
+       }
+#endif
+
+       destroy_ftran(f);
+#if WANT_FULLSCREEN
+       update_display(first_conn);
+#endif
+}
+
 /*
  * process_all_sendfiles():
  *             Sends data to all clients that are ready to receive it.
@@ -601,8 +624,15 @@ int process_all_sendfiles(fd_set * const active_clients, const int num_ac)
                f = next;
                next = f->next_ftran;
 
+#if HAVE_UPLOAD
+               if (f->upload == 1 && fds[f->sock].revents & POLLHUP) {
+                       finish_transfer(f);
+                       continue;
+               }
+#endif
+
 #if HAVE_POLL
-               if (fds[f->sock].revents & (POLLHUP|POLLERR|POLLNVAL)) {
+               if (fds[f->sock].revents & (POLLERR|POLLNVAL|POLLHUP)) {
                        destroy_ftran(f);
                        continue;
                }
@@ -610,7 +640,7 @@ int process_all_sendfiles(fd_set * const active_clients, const int num_ac)
 
                /* state = 2: incoming PASV, state >3: send file */
 #if HAVE_POLL
-               if ((f->state < 2) || (f->state == 3) ||  (fds[f->sock].revents & (POLLIN|POLLOUT)) == 0) {
+               if ((f->state < 2) || (f->state == 3) || (fds[f->sock].revents & (POLLIN|POLLOUT)) == 0) {
 #else
                if ((f->state < 2) || (f->state == 3) || !FD_ISSET(f->sock, active_clients)) {
 #endif
@@ -660,16 +690,7 @@ int process_all_sendfiles(fd_set * const active_clients, const int num_ac)
                        if (do_download(f)) continue;
 
                /* do_{upload,download} returned 0, the transfer is complete */
-                numeric(f->owner, 226, "Transfer complete.");
-                time(&(f->owner->last_transfer));
-
-#if WANT_XFERLOG
-                if (!f->dir_listing) {
-                       write_xferlog(f);
-               }
-#endif
-
-               destroy_ftran(f);
+               finish_transfer(f);
 #if WANT_FULLSCREEN
                 update_display(first_conn);
 #endif
diff --git a/ftpd.h b/ftpd.h
index 3110b10dd853f6fa2cb245a616246534ac2ca240..5ccd11fc39c2af2dc7777e13437a6a2f0cb2f7c1 100644 (file)
--- a/ftpd.h
+++ b/ftpd.h
@@ -184,6 +184,8 @@ void del_fd(const int fd);
 void destroy_conn(struct conn * const c);
 void destroy_ftran(struct ftran * const f);
 
+void finish_transfer(struct ftran * const f);
+
 #if HAVE_POLL
 int process_all_clients(const int num_ac);
 int process_all_sendfiles(const int num_ac);