widelands-dev team mailing list archive
-
widelands-dev team
-
Mailing list archive
-
Message #10162
[Merge] lp:~widelands-dev/widelands/bug-1690649-netclient into lp:widelands
Notabilis has proposed merging lp:~widelands-dev/widelands/bug-1690649-netclient into lp:widelands.
Requested reviews:
Widelands Developers (widelands-dev)
Related bugs:
Bug #1690649 in widelands: "crash in NetClient::is_connected()"
https://bugs.launchpad.net/widelands/+bug/1690649
For more details, see:
https://code.launchpad.net/~widelands-dev/widelands/bug-1690649-netclient/+merge/324129
This branch fixes a segfault when the metaserver closed the connection to the client. The bug triggers most of the time when you are logged in to the metaserver with one widelands instance and tries to log in with a second one.
The problem was that ... someone ;-) ... overlooked that handle_packet() can close the connection.
--
Your team Widelands Developers is requested to review the proposed merge of lp:~widelands-dev/widelands/bug-1690649-netclient into lp:widelands.
=== modified file 'src/network/internet_gaming.cc'
--- src/network/internet_gaming.cc 2017-05-11 06:31:35 +0000
+++ src/network/internet_gaming.cc 2017-05-16 18:38:11 +0000
@@ -262,16 +262,20 @@
if (error())
return;
try {
- assert(net != nullptr);
- // Check if the connection is still open
- if (!net->is_connected()) {
- handle_failed_read();
- return;
- }
- // Process all available packets
- RecvPacket packet;
- while (net->try_receive(&packet)) {
- handle_packet(packet);
+ while (net != nullptr) {
+ // Check if the connection is still open
+ if (!net->is_connected()) {
+ handle_failed_read();
+ return;
+ }
+ // Process all available packets
+ RecvPacket packet;
+ if (net->try_receive(&packet)) {
+ handle_packet(packet);
+ } else {
+ // Nothing more to receive
+ break;
+ }
}
} catch (const std::exception& e) {
logout((boost::format(_("Something went wrong: %s")) % e.what()).str());
Follow ups