Skip to content

Commit

Permalink
Merge pull request #18385 from shamser/issue31416
Browse files Browse the repository at this point in the history
HPCC-31416 CDistributedSuperFile::querySubFile may return incorrect subfile

Reviewed-by: Jake Smith <[email protected]>
Reviewed-by: Gavin Halliday <[email protected]>
Merged-by: Gavin Halliday <[email protected]>
  • Loading branch information
ghalliday authored Mar 22, 2024
2 parents 3bd0ef5 + e4b81e1 commit cf285fd
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions dali/base/dadfs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6271,22 +6271,27 @@ class CDistributedSuperFile: public CDistributedFileBase<IDistributedSuperFile>
virtual IDistributedFile &querySubFile(unsigned idx,bool sub) override
{
CriticalBlock block (sect);
if (sub) {
ForEachItemIn(i,subfiles) {
if (sub)
{
unsigned subfilen = idx;
ForEachItemIn(i,subfiles)
{
IDistributedFile &f=subfiles.item(i);
IDistributedSuperFile *super = f.querySuperFile();
if (super) {
if (super)
{
unsigned ns = super->numSubFiles(true);
if (ns>idx)
return super->querySubFile(idx,true);
idx -= ns;
if (ns>subfilen)
return super->querySubFile(subfilen,true);
subfilen -= ns;
}
else if (idx--==0)
else if (subfilen--==0)
return f;
}
// fall through to error
throw makeStringExceptionV(-1,"CDistributedSuperFile::querySubFile(%u) for superfile %s - subfile doesn't exist ", idx, logicalName.get());
}
return subfiles.item(idx);
else
return subfiles.item(idx);
}

virtual IDistributedFile *querySubFileNamed(const char *name, bool sub) override
Expand Down

0 comments on commit cf285fd

Please sign in to comment.