Skip to content

Conversation

@Ashod
Copy link
Contributor

@Ashod Ashod commented Nov 3, 2025

Simplifies the cleanup process at exit and ensures that cleanup() is always called.

wsd/COOLWSD.cpp Outdated
try
{
innerMain();
returnValue = cleanup(EXIT_OK);
Copy link
Contributor

Choose a reason for hiding this comment

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

cleanup can now be called multiple times; that doesn't smell like a good design

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I suppose if it throws. I moved it out, so if it throws that ends the process promptly.

Copy link
Contributor

Choose a reason for hiding this comment

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

Sorry, I don't get you What I meant was that when the call to cleanup in the try block threw, the catch blocks would have called cleanup a second time. (But you seem to have addressed that in b92c610 now, anyway?)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, that's what I meant by "if it throws" in the try, we'd call it (cleanup) again it the catch. Yes, addressed it.

wsd/COOLWSD.cpp Outdated

if constexpr (Util::isMobileApp())
Util::forcedExit(returnValue);

Copy link
Contributor

Choose a reason for hiding this comment

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

for IOS, all the above code wasn't originally executed, but now is

Copy link
Contributor Author

Choose a reason for hiding this comment

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

True. But on iOS we never run unit tests. Still, best to exclude them.

Copy link
Contributor

Choose a reason for hiding this comment

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

this is not only about the

        if (UnitBase::isUnitTesting())

but also about e.g. the

        if constexpr (Util::isMobileApp())
            Util::forcedExit(returnValue);

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, understood. Addressed.

@Ashod Ashod requested a review from stbergmann November 4, 2025 23:53
@stbergmann
Copy link
Contributor

stbergmann commented Nov 5, 2025

Ashod force-pushed the private/ash/exit branch from 57cfe33 to b92c610

I find the github PR review interface extremely hostile and hardly usable. Now, it appears that your new commit has a different parent than your old commit, so the "Compare" button leads to a page full of noise. I don't know how to meaningfully review such a PR.

@Ashod
Copy link
Contributor Author

Ashod commented Nov 5, 2025

Ashod force-pushed the private/ash/exit branch from 57cfe33 to b92c610

I find the github PR review interface extremely hostile and hardly usable. Now, it appears that your new commit has a different parent than your old commit, so the "Compare" button leads to a page full of noise. I don't know how to meaningfully review such a PR.

Understood. These are the diffs due to rebasing. I'll try to avoid that in the future.

Meanwhile, I'm hoping the PR is small enough, and your comments few enough that you can look at the parts we discussed. I'm hoping the changes are minor enough that you'll tell me if you still have any concerns.

wsd/COOLWSD.cpp Outdated
void COOLWSD::cleanup([[maybe_unused]] int returnValue)
int COOLWSD::cleanup(int returnValue)
{
if constexpr (Util::isMobileApp())
Copy link
Contributor

Choose a reason for hiding this comment

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

this shouldn't be done for IOS (for which Util::isMobileApp() is true AFAIU)

@stbergmann
Copy link
Contributor

And, on second thought, moving the Util::forcedExit(returnValue); into COOLWSD::cleanup is not nice: if COOLWSD::innerMain throws, we want to experience that (std::terminate), and not get the exception "swallowed" by the catch block around the call to innerMain calling cleanup -> forcedExit.

So, if you want to move the call to UnitBase::uninit() out of COOLWSD::innerMain, then maybe leave the

    if constexpr (Util::isMobileApp())
        Util::forcedExit(EXIT_SUCCESS);

there after all (on the, somewhat dubious, grounds that mobile apps don't run unit tests and thus don't need UnitBase::uninit, which you are already relying on here anyway)

@Ashod Ashod requested a review from stbergmann November 9, 2025 23:58
@Ashod
Copy link
Contributor Author

Ashod commented Nov 10, 2025

And, on second thought, moving the Util::forcedExit(returnValue); into COOLWSD::cleanup is not nice: if COOLWSD::innerMain throws, we want to experience that (std::terminate), and not get the exception "swallowed" by the catch block around the call to innerMain calling cleanup -> forcedExit.

Thanks, @stbergmann. This makes sense. I tried to retain the original IOS code while making sure that we do call the unit-test uninit in the case of exceptions.

I rebased, forgetting that it messes the diff. Please take a look at the diff as it is. It is now closer to the original and should be easy to re-review.

Thanks for your detailed reviews. Appreciated.

@github-project-automation github-project-automation bot moved this from To Review to To Test in Collabora Online Nov 11, 2025
Change-Id: Id1266613699f80350cc9a2098e63b3e76eca7ad7
Signed-off-by: Ashod Nakashian <[email protected]>
@Ashod Ashod merged commit 3db9af0 into master Nov 13, 2025
14 checks passed
@Ashod Ashod deleted the private/ash/exit branch November 13, 2025 11:45
@github-project-automation github-project-automation bot moved this from To Test to Done in Collabora Online Nov 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants