From bba9e152548371b7855ea2c96ce9bedfdf49e643 Mon Sep 17 00:00:00 2001 From: asomers Date: Mon, 1 Oct 2018 16:07:32 +0000 Subject: [PATCH] MFC r336587: tftpd(8): when completing an WRQ, flush the file before acknowleding receipt tftpd(8) should flush a newly written file to disk before ACKing the final DATA packet. Otherwise there is a narrow race window when a subsequent read may not see the file. This is somewhat related to r330710, but the race window is much smaller. Hopefully this will fix the intermittent tests in Jenkins. Reported by: Jenkins git-svn-id: svn://svn.freebsd.org/base/stable/10@339058 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f --- libexec/tftpd/tftp-transfer.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libexec/tftpd/tftp-transfer.c b/libexec/tftpd/tftp-transfer.c index 0311c07b0..9c350084a 100644 --- a/libexec/tftpd/tftp-transfer.c +++ b/libexec/tftpd/tftp-transfer.c @@ -277,6 +277,8 @@ tftp_receive(int peer, uint16_t *block, struct tftp_stats *ts, send_error(peer, ENOSPACE); goto abort; } + if (n_data != segsize) + write_close(); } send_ack: @@ -302,8 +304,6 @@ 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; -- 2.42.0