Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Correct the fh returned when reusing a handle from external table #1998

Merged
merged 1 commit into from
Apr 17, 2023

Conversation

smithdh
Copy link
Contributor

@smithdh smithdh commented Apr 14, 2023

This is a proposed fix for a problem seen with EOS; I suppose it's probably only possible with xrootd servers configured with plugins so that they use the delayed close feature (i.e. when the Ofs file close() can return SFS_STARTED).

I haven't opened an issue ticket for now (to describing what was seen, or attempts to reproduce the problem), but I could do so later if we want, but for now I won't. Essentially it seems the wrong file was closed or bytes were read from the wrong file.

This PR aims to correct the file handle number returned by XrdXrootdFileTable::Add() in case a heldSpot in the external table gets reused.

@amadio
Copy link
Member

amadio commented Apr 17, 2023

The fix looks good to me. However, It looks like the logic handling the FTab and XTab tables here is quite error-prone, so we should consider refactoring this a bit in the future. For example, rather than modifying i in place, we may call a find_file_handle(i, FTab), then if that fails, call find_file_handle(i - XRD_FTABSIZE, XTab) or something like that. We could also move from malloc/free to a std::array for FTab (since it seems to have a compile-time fixed size), and a std::vector for the XTab. At the very least, we could try using realloc to extend XTab. @abh What are your thoughts on this?

Comment on lines 218 to 222
else {i -= XRD_FTABSIZE;
if (XTab && i < XTnum) fP = &XTab[i];
else fP = 0;
i += XRD_FTABSIZE;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
else {i -= XRD_FTABSIZE;
if (XTab && i < XTnum) fP = &XTab[i];
else fP = 0;
i += XRD_FTABSIZE;
}
else {int ix = i - XRD_FTABSIZE;
if (XTab && ix < XTnum) fP = &XTab[ix];
else fP = 0;
}

@abh3
Copy link
Member

abh3 commented Apr 17, 2023 via email

@abh3
Copy link
Member

abh3 commented Apr 17, 2023 via email

@amadio
Copy link
Member

amadio commented Apr 17, 2023

Ok, I'm merging it then.

@amadio amadio merged commit 51c0f5b into xrootd:master Apr 17, 2023
14 checks passed
@amadio amadio added this to the 5.6 milestone Apr 17, 2023
@amadio amadio modified the milestones: 5.6, 5.5.5 May 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants