Skip to content

Commit

Permalink
fixed TTftpServerThread timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
Arnaud Bouchez committed Jun 13, 2023
1 parent 2dedaab commit 91c8bcd
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/mormot.commit.inc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
'2.1.5556'
'2.1.5557'
12 changes: 6 additions & 6 deletions src/net/mormot.net.tftp.server.pas
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ procedure TUdpServerThread.DoExecute;
OnFrameReceived(len, remote);
end;
end;
tix64 := GetTickCount64;
tix64 := mormot.core.os.GetTickCount64;
tix := tix64 shr 9;
if tix <> lasttix then
begin
Expand Down Expand Up @@ -330,7 +330,7 @@ procedure TTftpConnectionThread.DoExecute;
nr: TNetResult;
tix: Int64;
begin
tix := GetTickCount64;
tix := mormot.core.os.GetTickCount64;
fLog.Log(sllDebug, 'DoExecute % % %',
[fContext.Remote.IPShort({withport=}true), TFTP_OPCODE[fContext.OpCode],
fContext.FileName], self);
Expand All @@ -357,7 +357,7 @@ procedure TTftpConnectionThread.DoExecute;
fLog.Log(sllTrace, 'DoExecute recvfrom failed: %', [ToText(nr)^], self);
break;
end;
if GetTickCount64 >= fContext.TimeoutTix then
if mormot.core.os.GetTickCount64 < fContext.TimeoutTix then
// wait for incoming UDP packet within the timeout period
continue;
// retry after timeout
Expand Down Expand Up @@ -395,7 +395,7 @@ procedure TTftpConnectionThread.DoExecute;
fContext.RetryCount := fOwner.MaxRetry;
until Terminated;
// Destroy will call fContext.Shutdown
tix := GetTickCount64 - tix;
tix := mormot.core.os.GetTickCount64 - tix;
if tix <> 0 then
fLog.Log(sllTrace, 'DoExecute: % finished at %/s',
[fContext.FileName, KB((fFileSize * 1000) div tix)], self);
Expand Down Expand Up @@ -489,7 +489,7 @@ procedure TTftpServerThread.TerminateAndWaitFinished(TimeOutMs: integer);
endtix: Int64;
t: ^TTftpConnectionThread;
begin
endtix := GetTickCount64 + TimeOutMs;
endtix := mormot.core.os.GetTickCount64 + TimeOutMs;
// first notify all sub threads to terminate
NotifyShutdown;
// shutdown and wait for main accept() thread
Expand All @@ -500,7 +500,7 @@ procedure TTftpServerThread.TerminateAndWaitFinished(TimeOutMs: integer);
t := pointer(fConnection.List);
for i := 1 to fConnection.Count do
begin
t^.TerminateAndWaitFinished(endtix - GetTickCount64);
t^.TerminateAndWaitFinished(endtix - mormot.core.os.GetTickCount64);
inc(t);
end;
end;
Expand Down

0 comments on commit 91c8bcd

Please sign in to comment.