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

Fix #9255: [Network] TCPConnecter crashes when hostname not found #9259

Merged
merged 1 commit into from May 13, 2021

Conversation

TrueBrain
Copy link
Member

@TrueBrain TrueBrain commented May 12, 2021

Fixes #9255

Motivation / Problem

#9255 reports two problems:

  • ctor calls Resolve() which can call OnFailure which is not yet loaded at that point in time.
  • Resolve can call OnFailure while the game-state is not locked.

Description

By solving the second the first automagically solves itself, but I think it is a pitfall the next person will in before you know it. As such, I also addressed the first one. Call it overkill.

Basically:

  • OnFailure in Resolve is delayed till the game-state is locked (in CheckActivity, which guarantees this).
  • Resolve is called from CheckActivity and no longer in the ctor.

I could combine both nicely in a single enum, which also helps understanding a bit more what the step are that are taken by the resolvement.

The status is not updated to failure/success in CheckActivity itself, as both result in a return true which will destroy the object seconds later. In other words, nobody will be able to read this updated status anyway.

Limitations

Checklist for review

Some things are not automated, and forgotten often. This list is a reminder for the reviewers.

  • The bug fix is important enough to be backported? (label: 'backport requested')
  • This PR affects the save game format? (label 'savegame upgrade')
  • This PR affects the GS/AI API? (label 'needs review: Script API')
    • ai_changelog.hpp, gs_changelog.hpp need updating.
    • The compatibility wrappers (compat_*.nut) need updating.
  • This PR affects the NewGRF API? (label 'needs review: NewGRF')

@TrueBrain TrueBrain changed the title Fix #9257: [Network] TCPConnecter crashes when hostname not found Fix #9255: [Network] TCPConnecter crashes when hostname not found May 12, 2021
@TrueBrain TrueBrain force-pushed the fix-connector-resolve branch 3 times, most recently from ce4c75e to e4454e4 Compare May 12, 2021 22:01
src/network/core/tcp.h Outdated Show resolved Hide resolved
rubidium42
rubidium42 previously approved these changes May 12, 2021
@TrueBrain TrueBrain merged commit d7ce61f into OpenTTD:master May 13, 2021
@TrueBrain TrueBrain deleted the fix-connector-resolve branch May 13, 2021 06:13
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.

Threading issues with the TCPConnecters
2 participants