Skip to content

close Admin::Document smaps file when document is expired #11741

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

Merged

Conversation

caolanm
Copy link
Contributor

@caolanm caolanm commented Apr 24, 2025

Admin::Documents are moved to _expiredDocuments when the matching real document is closed. At which point _memoryDirty won't be updated anymore so we can close the open FILE* to the removed process smaps file to release a fd, and drop the FILE buffer.

Change-Id: Ied919f6e0fe614be7ad42cc15ddca60f0a4adab2

  • Resolves: #
  • Target version: master

Summary

TODO

  • ...

Checklist

  • I have run make prettier-write and formatted the code.
  • All commits have Change-Id
  • I have run tests with make check
  • I have issued make run and manually verified that everything looks okay
  • Documentation (manuals or wiki) has been updated or is not required

Copy link
Contributor

@mmeeks mmeeks left a comment

Choose a reason for hiding this comment

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

Looks very sensible =) but quite small as a win.

@github-project-automation github-project-automation bot moved this from To Review to To Test in Collabora Online Apr 24, 2025
Admin::Documents are moved to _expiredDocuments when the matching real
document is closed and are persistent until coolwsd exits, keeping
the FILE* associated buffers around for coolwsds lifetime.

fclose always uses ::close on its fd, but wasn't typically called
before now, and ChildProcess always closed the fd. If we starting
calling fclose then there is a duplicate ::close.

By moving the FILE* to the ChildProcess, managed by shared_ptr,
we can avoid having a permanently open FILE* in _expiredDocuments
and avoid dup() for extra fds and guessing games as to who should
close the smaps file.

Signed-off-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Change-Id: Ied919f6e0fe614be7ad42cc15ddca60f0a4adab2
@caolanm
Copy link
Contributor Author

caolanm commented Apr 24, 2025

Nah, that's not going to work, ChildProcess does ::close on the underlying fd, so a fclose on the Admin::Documents FILE* from its fdopen of that is a second ::close. So we're relying on never calling fclose in practice at the moment.

We'd need to dup the fd if we want to fclose the FILE* later. Or take ownership of the fd and hope for the best as it bounces around AdminModel callbacks.

@caolanm caolanm force-pushed the private/caolan/close_expired_admin_document_smaps_file branch from 862ed25 to 2c0388b Compare April 24, 2025 20:43
Copy link
Contributor

@Ashod Ashod left a comment

Choose a reason for hiding this comment

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

Thanks, @caolanm. As discussed offline, I'm made the expired-documents obsolete, but these changes look good in general. I'll deal with the conflicts and push, but let's get these in first.

@caolanm caolanm merged commit ac5bfa2 into master Apr 28, 2025
14 checks passed
@caolanm caolanm deleted the private/caolan/close_expired_admin_document_smaps_file branch April 28, 2025 12:48
@github-project-automation github-project-automation bot moved this from To Test to Done in Collabora Online Apr 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

3 participants