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

Several network code related fixes (four for one special!) #9216

Merged
merged 4 commits into from May 8, 2021

Conversation

TrueBrain
Copy link
Member

Motivation / Problem

  • TCPConnecter dtor was making illegal writes/reads when killed before resolving was done
  • You couldn't query two servers at once

Both required fixing. And I had 2 code cleanups in my queue .. might as well add them.

Description

TCPConnecter dtor was a bit evil, as two problems intersected:

  • connection_string was already free'd before the dtor of TCPConnecter was called. This was not expected. But because private/public wasn't set correctly for it, TCPQueryConnecter was already freeing the memory in his ctor. This was unintentional.
  • TCPConnecter didn't join the resolve thread, so it could still be pending, and reading/writing information. Now instead, wait till the resolve thread finishes before destroying TCPConnecter.
  • NetworkTCPQueryServer disconnected the network. No clue why .. most likely once that sounded like a good idea, but it is totally unneeded now.
  • If you added a server that was already on the master-server listing, it was never marked as manual. So a game client restart still didn't make it show up. That is unexpected.
  • While at it, also only query a server again if we didn't already have info about it. No need to constantly request information of a server .. it is unlikely to have changed.

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')

The most common case never needs access to it anymore. Make the
one exception to this explicit. This means the fact that we
store it is now an implementation detail.
…writes

Basically, we should join the resolve thread before we destruct
the object.
This meant that on opening the Multiplayer window, if you had more
than one server configured, it would one by one cancel all pending
queries and send a new. Result: only the last server was updated.
But always mark it as manually, no matter if it was there or not.
Copy link
Member

@LordAro LordAro left a comment

Choose a reason for hiding this comment

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

Seems fine

@TrueBrain TrueBrain merged commit b9ab3bd into OpenTTD:master May 8, 2021
@TrueBrain TrueBrain deleted the happy-eyeballs-fix-two branch May 8, 2021 15:26
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

2 participants