From 7378015b694df3fbbc8cf51fe5ed352701f20e01 Mon Sep 17 00:00:00 2001 From: Alan Somers Date: Sat, 21 Jul 2018 19:48:31 +0000 Subject: [PATCH] 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 MFC after: 2 weeks --- 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 052714fb5a2e..c2c9e0793354 100644 --- a/libexec/tftpd/tftp-transfer.c +++ b/libexec/tftpd/tftp-transfer.c @@ -279,6 +279,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: @@ -304,8 +306,6 @@ tftp_receive(int peer, uint16_t *block, struct tftp_stats *ts, 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;