mail[Wesnoth-commits] r24960 - in /branches/1.4/src/server: game.cpp game.hpp server.cpp


Others Months | Index by Date | Thread Index
>>   [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Header


Content

Posted by soliton . de on March 22, 2008 - 06:01:
Author: soliton
Date: Sat Mar 22 06:01:40 2008
New Revision: 24960

URL: http://svn.gna.org/viewcvs/wesnoth?rev=24960&view=rev
Log:
* added extra assertions to track causes of crash
* also exit explicitely on SIGTERM
* correct some server messages
(merged r24956-r24959 from trunk)

Modified:
    branches/1.4/src/server/game.cpp
    branches/1.4/src/server/game.hpp
    branches/1.4/src/server/server.cpp

Modified: branches/1.4/src/server/game.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/branches/1.4/src/server/game.cpp?rev=24960&r1=24959&r2=24960&view=diff
==============================================================================
--- branches/1.4/src/server/game.cpp (original)
+++ branches/1.4/src/server/game.cpp Sat Mar 22 06:01:40 2008
@@ -959,7 +959,7 @@
                << (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 @@
 
 //! 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 @@
        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 @@
        }
 
        if(sock) {
-               simple_wml::string_span str = doc.output_compressed();
-               network::send_raw_data(str.begin(), str.size(), sock);
-       }
-}
+               send_to_one(doc, sock);
+       }
+}

Modified: branches/1.4/src/server/game.hpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/branches/1.4/src/server/game.hpp?rev=24960&r1=24959&r2=24960&view=diff
==============================================================================
--- branches/1.4/src/server/game.hpp (original)
+++ branches/1.4/src/server/game.hpp Sat Mar 22 06:01:40 2008
@@ -87,7 +87,7 @@
        //! 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,

Modified: branches/1.4/src/server/server.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/branches/1.4/src/server/server.cpp?rev=24960&r1=24959&r2=24960&view=diff
==============================================================================
--- branches/1.4/src/server/server.cpp (original)
+++ branches/1.4/src/server/server.cpp Sat Mar 22 06:01:40 2008
@@ -75,6 +75,12 @@
 void exit_sigint(int signal) {
        assert(signal == SIGINT);
        LOG_SERVER << "SIGINT caught, exiting without cleanup immediately.\n";
+       exit(1);
+}
+
+void exit_sigterm(int signal) {
+       assert(signal == SIGTERM);
+       LOG_SERVER << "SIGTERM caught, exiting without cleanup 
immediately.\n";
        exit(1);
 }
 
@@ -280,6 +286,7 @@
        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 @@
 
        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 @@
                                << 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 @@
                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 @@
                                        + 
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);




Related Messages


Powered by MHonArc, Updated Sat Mar 22 06:21:06 2008