Copyright (C) 1999-2000 Steinar H. Gunderson
This program is is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License, version 2 if the
+ it under the terms of the GNU General Public License, version 2 of the
License as published by the Free Software Foundation.
This program is distributed in the hope that it will be useful,
#include <stropts.h>
#endif
+#if HAVE_SYS_TYPES_H
+#include <sys/types.h>
+#endif
+
#if HAVE_SYS_CONF_H
#include <sys/conf.h>
#endif
#include <unistd.h>
#endif
-#if HAVE_ARPA_INET_H
-#include <arpa/inet.h>
-#endif
-
-#if HAVE_SYS_STAT_H
-#include <sys/stat.h>
-#endif
-
-#if HAVE_SYS_IOCTL_H
-#include <sys/ioctl.h>
-#endif
-
#if HAVE_NETINET_IN_SYSTM_H
#include <netinet/in_systm.h>
#endif
+#if HAVE_NETINET_IN_H
+#include <netinet/in.h>
+#endif
+
#if HAVE_NETINET_IP_H
#include <netinet/ip.h>
#endif
#include <netinet/tcp.h>
#endif
+#if HAVE_ARPA_INET_H
+#include <arpa/inet.h>
+#endif
+
+#if HAVE_SYS_STAT_H
+#include <sys/stat.h>
+#endif
+
+#if HAVE_SYS_IOCTL_H
+#include <sys/ioctl.h>
+#endif
+
#if HAVE_LINUX_SOCKET_H
#include <linux/socket.h>
#endif
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.
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;
}
/* 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
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