Author: suokko
Date: Fri Jun 27 21:58:18 2008
New Revision: 27539

URL: http://svn.gna.org/viewcvs/wesnoth?rev=27539&view=rev
Log:
Made server automaticaly output bandwidth profiling stats to log

Modified:
    branches/1.4/src/network.cpp
    branches/1.4/src/server/server.cpp

Modified: branches/1.4/src/network.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/branches/1.4/src/network.cpp?rev=27539&r1=27538&r2=27539&view=diff
==============================================================================
--- branches/1.4/src/network.cpp (original)
+++ branches/1.4/src/network.cpp Fri Jun 27 21:58:18 2008
@@ -894,14 +894,15 @@
        int day = timeinfo->tm_mday;
        assert(hour < 24 && hour >= 0);
        std::pair<bandwidth_map::iterator,bool> insertion = 
hour_stats[hour].insert(std::make_pair(packet_type, bandwidth_stats()));
+       bandwidth_map::iterator& inserted = insertion.first;
        if (!insertion.second && day != inserted->second.day)
        {
                // clear previuos day stats
-               hour[hour].clear();
+               hour_stats[hour].clear();
                //insert again to cleared map
                insertion = hour_stats[hour].insert(std::make_pair(packet_type, 
bandwidth_stats()));
-       }
-       bandwidth_map::iterator inserted = insertion.first;
+               inserted = insertion.first;
+       }
        inserted->second.day = day;
        return inserted;
 }

Modified: branches/1.4/src/server/server.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/branches/1.4/src/server/server.cpp?rev=27539&r1=27538&r2=27539&view=diff
==============================================================================
--- branches/1.4/src/server/server.cpp (original)
+++ branches/1.4/src/server/server.cpp Fri Jun 27 21:58:18 2008
@@ -483,6 +483,16 @@
                        if ((loop%100) == 0 && last_ping_ + 10 <= now) {
                                // Make sure we log stats every 5 minutes
                                if (last_stats_ + 5*60 <= now) dump_stats(now);
+#ifdef BANDWIDTH_MONITOR
+                               // Send network stats every hour
+                               static size_t prev_hour = 
localtime(&now)->tm_hour;
+                               if (prev_hour != localtime(&now)->tm_hour)
+                               {
+                                       prev_hour = localtime(&now)->tm_hour;
+                                       LOG_SERVER << 
network::get_bandwidth_stats();
+
+                               }
+#endif
                                // send a 'ping' to all players to detect ghosts
                                config ping;
                                ping["ping"] = lexical_cast<std::string>(now);
@@ -849,7 +859,7 @@
        } else if (command == "status") {
                response << process_command(command.to_string() + " " + 
pl->second.name());
        } else if (command == "status " + pl->second.name() || command == 
"metrics"
-       || command == "motd" || command == "wml" || command == "netstats" || 
command == "netstats all") {
+       || command == "motd" || command == "wml" || command == "netstats") {
                response << process_command(command.to_string());
        } else if (command == admin_passwd_) {
                LOG_SERVER << "New Admin recognized:" << "\tIP: "


_______________________________________________
Wesnoth-commits mailing list
[email protected]
https://mail.gna.org/listinfo/wesnoth-commits

Reply via email to