Skip to content

Fix client disconnection logic and add IP address retrieval and#484

Open
Neptnium wants to merge 1 commit into
BeamMP:minorfrom
Neptnium:483-fix-crash-on-improper-disconnect
Open

Fix client disconnection logic and add IP address retrieval and#484
Neptnium wants to merge 1 commit into
BeamMP:minorfrom
Neptnium:483-fix-crash-on-improper-disconnect

Conversation

@Neptnium
Copy link
Copy Markdown
Contributor

Fixes #483 that was created after the merge of #478.
I also took the freedom to switch the mutex locking to a lockguard for safety reasons.


By creating this pull request, I understand that code that is AI generated or otherwise automatically generated may be rejected without further discussion.
I declare that I fully understand all code I pushed into this PR, and wrote all this code myself and own the rights to this code.

@WiserTixx WiserTixx requested a review from SaltySnail April 18, 2026 17:11
Comment thread src/Client.cpp
Comment on lines +152 to +156
boost::system::error_code ec;
auto ep = mSocket.remote_endpoint(ec);
if (!ec) {
mIP = ep.address().to_string();
}
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Is there a reason why the error code isn't handled here?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

'ec' beeing the error code I don't see what you're saying, could you please explain ?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

If there is an error the ip is skipped and then the client construction is finished. However if the remote_endpoint call failed I don't see why we'd need to keep the client. The error also isn't logged making things harder to debug.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Oh, well this is something I did not think about, do you want me to change it ?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Yes, that would be preferred.

@SaltySnail
Copy link
Copy Markdown
Collaborator

I think this PR is deprecated by #489
However we can see what the changes compare to when 489 is merged

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.

[BUG] Server crashes when connection is not closed properly

3 participants