Skip to content

Commit 5612cfe

Browse files
authored
Merge pull request #243 from avinxshKD/fix/matlab-retry-loop-safeguards
Fix MATLAB retry loop hang and crashes in concore_read.m
2 parents a1fdd2f + 0949fc0 commit 5612cfe

1 file changed

Lines changed: 13 additions & 4 deletions

File tree

concore_read.m

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,21 @@
88
catch exc
99
ins = inistr;
1010
end
11-
while length(ins) == 0
11+
maxretries = 5;
12+
attempts = 0;
13+
while length(ins) == 0 && attempts < maxretries
1214
pause(concore.delay);
13-
input1 = fopen(strcat(concore.inpath,num2str(port),'/',name));
14-
ins = fscanf(input1,'%c');
15-
fclose(input1);
15+
try
16+
input1 = fopen(strcat(concore.inpath,num2str(port),'/',name));
17+
ins = fscanf(input1,'%c');
18+
fclose(input1);
19+
catch exc
20+
end
1621
concore.retrycount = concore.retrycount + 1;
22+
attempts = attempts + 1;
23+
end
24+
if length(ins) == 0
25+
ins = inistr;
1726
end
1827
concore.s = strcat(concore.s, ins);
1928
result = eval(ins);

0 commit comments

Comments
 (0)