Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 14 additions & 6 deletions tftp/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,18 +116,26 @@ def blockWriteSuccess(self, ign, datagram):

"""
bytes = ACKDatagram(datagram.blocknum).to_wire()
self.timeout_watchdog = SequentialCall.run(self.timeout[:-1],
callable=self.sendData, callable_args=[bytes, ],
on_timeout=lambda: self._clock.callLater(self.timeout[-1], self.timedOut),
run_now=True,
_clock=self._clock
)
if len(datagram.data) < self.block_size:
self._clock.callLater(0, self.sendData, bytes)
self.timeout_watchdog = SequentialCall.run(self.timeout[:-1],
callable=lambda: None,
on_timeout=lambda: self._clock.callLater(self.timeout[-1], self.timedOut),
run_now=False,
_clock=self._clock
)
self.completed = True
self.writer.finish()
# TODO: If self.tsize is not None, compare it with the actual
# count of bytes written. Log if there's a mismatch. Should it
# also emit an error datagram?
else:
self.timeout_watchdog = SequentialCall.run(self.timeout[:-1],
callable=self.sendData, callable_args=[bytes, ],
on_timeout=lambda: self._clock.callLater(self.timeout[-1], self.timedOut),
run_now=True,
_clock=self._clock
)

def blockWriteFailure(self, failure):
"""Write failed"""
Expand Down