diff options
author | Alan Somers <asomers@FreeBSD.org> | 2018-03-09 23:25:18 +0000 |
---|---|---|
committer | Alan Somers <asomers@FreeBSD.org> | 2018-03-09 23:25:18 +0000 |
commit | d3953c1f478f7933f905cfb85ef8ea7a08133e19 (patch) | |
tree | bc94d3145a8bfe3fa1fcc2ea9538d40f9da26b12 /libexec | |
parent | c60fdff77d035caa09ae2dcebe6be7d1deb1da54 (diff) | |
download | src-d3953c1f478f7933f905cfb85ef8ea7a08133e19.tar.gz src-d3953c1f478f7933f905cfb85ef8ea7a08133e19.zip |
tftpd: Flush files as soon as they are fully received
On an RRQ, tftpd doesn't exit as soon as it's finished receiving a file.
Instead, it waits five seconds just in case the client didn't receive the
server's last ACK and decides to resend the final DATA packet.
Unfortunately, this created a 5 second delay from when the client thinks
it's done sending the file, and when the file is available for other
processes.
Fix this bug by closing the file as soon as receipt is finished.
PR: 157700
Reported by: Barry Mishler <barry_mishler@yahoo.com>
MFC after: 3 weeks
Notes
Notes:
svn path=/head/; revision=330710
Diffstat (limited to 'libexec')
-rw-r--r-- | libexec/tftpd/tests/functional.c | 9 | ||||
-rw-r--r-- | libexec/tftpd/tftp-transfer.c | 2 | ||||
-rw-r--r-- | libexec/tftpd/tftpd.c | 1 |
3 files changed, 3 insertions, 9 deletions
diff --git a/libexec/tftpd/tests/functional.c b/libexec/tftpd/tests/functional.c index 62e1af2df90a..d7f5ac77f81b 100644 --- a/libexec/tftpd/tests/functional.c +++ b/libexec/tftpd/tests/functional.c @@ -694,7 +694,6 @@ TFTPD_TC_DEFINE(w_flag,, w_flag = 1;) send_data(1, contents, contents_len); recv_ack(1); - atf_tc_expect_fail("PR 157700 tftpd expects more data after EOF"); fd = open("small.txt", O_RDONLY); r = read(fd, buffer, sizeof(buffer)); close(fd); @@ -731,7 +730,6 @@ TFTPD_TC_DEFINE(wrq_dropped_ack,) send_data(2, (const char*)&contents[128], 256); recv_ack(2); - atf_tc_expect_fail("PR 157700 tftpd expects more data after EOF"); fd = open("medium.txt", O_RDONLY); r = read(fd, buffer, sizeof(buffer)); close(fd); @@ -764,7 +762,6 @@ TFTPD_TC_DEFINE(wrq_dropped_data,) send_data(1, contents, contents_len); recv_ack(1); - atf_tc_expect_fail("PR 157700 tftpd expects more data after EOF"); fd = open("small.txt", O_RDONLY); r = read(fd, buffer, sizeof(buffer)); close(fd); @@ -798,7 +795,6 @@ TFTPD_TC_DEFINE(wrq_duped_data,) send_data(2, (const char*)&contents[128], 256); recv_ack(2); - atf_tc_expect_fail("PR 157700 tftpd expects more data after EOF"); fd = open("medium.txt", O_RDONLY); r = read(fd, buffer, sizeof(buffer)); close(fd); @@ -865,7 +861,6 @@ TFTPD_TC_DEFINE(wrq_medium,) send_data(2, (const char*)&contents[128], 256); recv_ack(2); - atf_tc_expect_fail("PR 157700 tftpd expects more data after EOF"); fd = open("medium.txt", O_RDONLY); r = read(fd, buffer, sizeof(buffer)); close(fd); @@ -891,14 +886,13 @@ TFTPD_TC_DEFINE(wrq_netascii,) fd = open("unix.txt", O_RDWR | O_CREAT, 0666); ATF_REQUIRE(fd >= 0); close(fd); - contents_len = strlen(contents) + 1; + contents_len = sizeof(contents); SEND_WRQ("unix.txt", "netascii"); recv_ack(0); send_data(1, contents, contents_len); recv_ack(1); - atf_tc_expect_fail("PR 157700 tftpd expects more data after EOF"); fd = open("unix.txt", O_RDONLY); r = read(fd, buffer, sizeof(buffer)); close(fd); @@ -938,7 +932,6 @@ TFTPD_TC_DEFINE(wrq_small,) send_data(1, contents, contents_len); recv_ack(1); - atf_tc_expect_fail("PR 157700 tftpd expects more data after EOF"); fd = open("small.txt", O_RDONLY); r = read(fd, buffer, sizeof(buffer)); close(fd); diff --git a/libexec/tftpd/tftp-transfer.c b/libexec/tftpd/tftp-transfer.c index 8870b3651055..052714fb5a2e 100644 --- a/libexec/tftpd/tftp-transfer.c +++ b/libexec/tftpd/tftp-transfer.c @@ -304,6 +304,8 @@ send_ack: gettimeofday(&(ts->tstop), NULL); } while (n_data == segsize); + write_close(); + /* Don't do late packet management for the client implementation */ if (acting_as_client) return; diff --git a/libexec/tftpd/tftpd.c b/libexec/tftpd/tftpd.c index e8ae35506ae3..a167395d5832 100644 --- a/libexec/tftpd/tftpd.c +++ b/libexec/tftpd/tftpd.c @@ -823,7 +823,6 @@ tftp_recvfile(int peer, const char *mode) block = 0; tftp_receive(peer, &block, &ts, NULL, 0); - write_close(); gettimeofday(&now2, NULL); if (debug&DEBUG_SIMPLE) { |