Skip to content

Commit cba79f0

Browse files
authored
Merge pull request #250 from espressif/fix/indefinite_loop
fix(performcmdinstall): Exit blocking wait loop after some time to no…
2 parents 50fd774 + a4a0f49 commit cba79f0

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/InnoSetup/Pages/CmdlinePage.iss

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ var
115115
LogText, LeftOver: String;
116116
Memo: TNewMemo;
117117
PrevCancelButtonOnClick: TNotifyEvent;
118+
MaxIterations: Integer;
118119
begin
119120
CmdlineInstallPage := CreateOutputProgressPage('', '')
120121
CmdlineInstallPage.Caption := caption;
@@ -147,7 +148,13 @@ begin
147148
Log('ProcStart failed');
148149
ExitCode := -2;
149150
end;
150-
while (ExitCode = -1) and not CmdlineInstallCancel do
151+
152+
{ Following number MaxIterations is not hard defined }
153+
{ it only has to be based on execution times of the instructions inside the loop and CPU ticks }
154+
{ to fulfill this need heuristic technique was applied to define this number }
155+
{ also, it has been taken into mind the loop has to exit within 5 minutes which is probably the maximal time user would wait }
156+
MaxIterations := 40000;
157+
while (ExitCode = -1) and not CmdlineInstallCancel and not (MaxIterations = 0) do
151158
begin
152159
ExitCode := ProcGetExitCode(Handle);
153160
SetLength(LogTextAnsi, 4096);
@@ -160,6 +167,7 @@ begin
160167
end;
161168
CmdlineInstallPage.SetProgress(0, 100);
162169
Sleep(10);
170+
MaxIterations := MaxIterations - 1;
163171
end;
164172
ProcEnd(Handle);
165173
finally

0 commit comments

Comments
 (0)