added extra assertions to track causes of crash
also exit explicitely on SIGTERM correct some server messages (merged 2008-03-22T02:13:51Z!davewx7@gmail.com-2008-03-22T04:55:46Z!soliton@wesnoth.org from trunk)
This commit is contained in:
parent
a09236ea33
commit
6032f5ac94
3 changed files with 20 additions and 9 deletions
|
@ -959,7 +959,7 @@ bool game::remove_player(const network::connection player, const bool disconnect
|
|||
<< (disconnect ? " and disconnected" : "")
|
||||
<< ". (socket: " << user->first << ")\n";
|
||||
if (game_ended) {
|
||||
send_server_message((user->second.name() + " ended the game.").c_str(), player);
|
||||
send_server_message_to_all((user->second.name() + " ended the game.").c_str(), player);
|
||||
return true;
|
||||
}
|
||||
// Don't mark_available() since the player got already removed from the
|
||||
|
@ -1030,7 +1030,7 @@ void game::send_user_list(const network::connection exclude) const {
|
|||
|
||||
//! A member asks for the next scenario to advance to.
|
||||
void game::load_next_scenario(const player_map::const_iterator user) const {
|
||||
send_server_message((user->second.name() + " advances to the next scenario").c_str(), user->first);
|
||||
send_server_message_to_all((user->second.name() + " advances to the next scenario").c_str(), user->first);
|
||||
simple_wml::document cfg_scenario;
|
||||
level_.root().copy_into(cfg_scenario.root().add_child("next_scenario"));
|
||||
simple_wml::string_span data = cfg_scenario.output_compressed();
|
||||
|
@ -1214,11 +1214,11 @@ void game::send_and_record_server_message(const char* message,
|
|||
record_data(doc);
|
||||
}
|
||||
|
||||
void game::send_server_message_to_all(const char* message) const
|
||||
void game::send_server_message_to_all(const char* message, network::connection exclude) const
|
||||
{
|
||||
simple_wml::document doc;
|
||||
send_server_message(message, 0, &doc);
|
||||
send_data(doc);
|
||||
send_data(doc, exclude);
|
||||
}
|
||||
|
||||
void game::send_server_message(const char* message, network::connection sock, simple_wml::document* docptr) const
|
||||
|
@ -1242,7 +1242,6 @@ void game::send_server_message(const char* message, network::connection sock, si
|
|||
}
|
||||
|
||||
if(sock) {
|
||||
simple_wml::string_span str = doc.output_compressed();
|
||||
network::send_raw_data(str.begin(), str.size(), sock);
|
||||
send_to_one(doc, sock);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -87,7 +87,7 @@ public:
|
|||
//! Returns true iff the number of slots has changed.
|
||||
bool describe_slots();
|
||||
|
||||
void send_server_message_to_all(const char* message) const;
|
||||
void send_server_message_to_all(const char* message, network::connection exclude=0) const;
|
||||
void send_server_message(const char* message, network::connection sock=0, simple_wml::document* doc=NULL) const;
|
||||
//! Send data to all players in this game except 'exclude'.
|
||||
void send_and_record_server_message(const char* message,
|
||||
|
|
|
@ -78,6 +78,12 @@ void exit_sigint(int signal) {
|
|||
exit(1);
|
||||
}
|
||||
|
||||
void exit_sigterm(int signal) {
|
||||
assert(signal == SIGTERM);
|
||||
LOG_SERVER << "SIGTERM caught, exiting without cleanup immediately.\n";
|
||||
exit(1);
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
||||
// we take profiling info on every n requests
|
||||
|
@ -280,6 +286,7 @@ server::server(int port, input_stream& input, const std::string& config_file, si
|
|||
load_config();
|
||||
signal(SIGHUP, reload_config);
|
||||
signal(SIGINT, exit_sigint);
|
||||
signal(SIGTERM, exit_sigterm);
|
||||
}
|
||||
|
||||
void server::send_error(network::connection sock, const char* msg) const
|
||||
|
@ -765,7 +772,7 @@ void server::process_login(const network::connection sock,
|
|||
|
||||
for (std::vector<game*>::const_iterator g = games_.begin(); g != games_.end(); ++g) {
|
||||
// Note: This string is parsed by the client to identify lobby join messages!
|
||||
(*g)->send_server_message((username + " has logged into the lobby").c_str());
|
||||
(*g)->send_server_message_to_all((username + " has logged into the lobby").c_str());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1198,6 +1205,9 @@ void server::process_data_game(const network::connection sock,
|
|||
<< g->id() << ") although it's already initialized.\n";
|
||||
return;
|
||||
}
|
||||
|
||||
assert(games_and_users_list_.child("gamelist")->children("game").empty() == false);
|
||||
|
||||
simple_wml::node& desc = *g->description();
|
||||
// Update the game's description.
|
||||
// If there is no shroud, then tell players in the lobby
|
||||
|
@ -1242,6 +1252,8 @@ void server::process_data_game(const network::connection sock,
|
|||
g->update_side_data();
|
||||
g->describe_slots();
|
||||
|
||||
assert(games_and_users_list_.child("gamelist")->children("game").empty() == false);
|
||||
|
||||
// Send the update of the game description to the lobby.
|
||||
simple_wml::document diff;
|
||||
make_add_diff(*games_and_users_list_.child("gamelist"), "gamelist", "game", diff);
|
||||
|
@ -1345,7 +1357,7 @@ void server::process_data_game(const network::connection sock,
|
|||
+ lexical_cast_default<std::string,size_t>(g->current_turn())
|
||||
+ " with reason: '" + g->termination_reason() + "'" : "")
|
||||
<< ".\n";
|
||||
g->send_server_message((pl->second.name() + " ended the game.").c_str(), pl->first);
|
||||
g->send_server_message_to_all((pl->second.name() + " ended the game.").c_str(), pl->first);
|
||||
// Remove the player in delete_game() with all other remaining
|
||||
// ones so he gets the updated gamelist.
|
||||
delete_game(itor);
|
||||
|
|
Loading…
Add table
Reference in a new issue