Author: suokko
Date: Wed Sep 3 03:22:52 2008
New Revision: 29231
URL: http://svn.gna.org/viewcvs/wesnoth?rev=29231&view=rev
Log:
Removed bandwidth monitor perprocessor test, It is now included allways
Modified:
trunk/src/Makefile.am
trunk/src/network.cpp
trunk/src/network.hpp
trunk/src/network_worker.cpp
trunk/src/network_worker.hpp
trunk/src/server/server.cpp
Modified: trunk/src/Makefile.am
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/Makefile.am?rev=29231&r1=29230&r2=29231&view=diff
==============================================================================
--- trunk/src/Makefile.am (original)
+++ trunk/src/Makefile.am Wed Sep 3 03:22:52 2008
@@ -231,12 +231,7 @@
time.cpp \
loadscreen_empty.cpp
-wesnothd_compilerflags = $(AM_CXXFLAGS)
-if BANDWIDTH_MONITOR
-wesnothd_compilerflags += -DBANDWIDTH_MONITOR
-endif
-wesnothd_CXXFLAGS = $(wesnothd_compilerflags)
wesnothd_LDADD = -L. -lwesnoth-core $(BOOST_IOSTREAMS_LIBS) @SDL_NET_LIBS@
@SDL_LIBS@ $(LIBINTL)
wesnothd_DEPENDENCIES=libwesnoth-core.a
Modified: trunk/src/network.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/network.cpp?rev=29231&r1=29230&r2=29231&view=diff
==============================================================================
--- trunk/src/network.cpp (original)
+++ trunk/src/network.cpp Wed Sep 3 03:22:52 2008
@@ -647,19 +647,11 @@
disconnection_queue.push_back(sock);
}
-connection receive_data(config& cfg, connection connection_num, unsigned int
timeout
-#ifdef BANDWIDTH_MONITOR
- , bandwidth_in_ptr* bandwidth_in
-#endif
- )
+connection receive_data(config& cfg, connection connection_num, unsigned int
timeout, bandwidth_in_ptr* bandwidth_in)
{
unsigned int start_ticks = SDL_GetTicks();
while(true) {
- const connection res = receive_data(cfg,connection_num
-#ifdef BANDWIDTH_MONITOR
- ,(bool*)0 , bandwidth_in
-#endif
- );
+ const connection res = receive_data(cfg,connection_num,(bool*)0
, bandwidth_in);
if(res != 0) {
return res;
}
@@ -677,11 +669,7 @@
return 0;
}
-connection receive_data(config& cfg, connection connection_num, bool* gzipped
-#ifdef BANDWIDTH_MONITOR
- , bandwidth_in_ptr* bandwidth_in
-#endif
- )
+connection receive_data(config& cfg, connection connection_num, bool* gzipped,
bandwidth_in_ptr* bandwidth_in)
{
if(!socket_set) {
return 0;
@@ -736,18 +724,12 @@
TCPsocket sock = connection_num == 0 ? 0 : get_socket(connection_num);
TCPsocket s = sock;
-#ifdef BANDWIDTH_MONITOR
bandwidth_in_ptr temp;
if (!bandwidth_in)
{
bandwidth_in = &temp;
}
-#endif
- sock = network_worker_pool::get_received_data(sock,cfg, gzipped
-#ifdef BANDWIDTH_MONITOR
- , *bandwidth_in
-#endif
- );
+ sock = network_worker_pool::get_received_data(sock,cfg, gzipped,
*bandwidth_in);
if (sock == NULL) {
if (!is_server() && last_ping != 0 && ping_timeout != 0)
{
@@ -797,11 +779,7 @@
return result;
}
-connection receive_data(std::vector<char>& buf
-#ifdef BANDWIDTH_MONITOR
- , bandwidth_in_ptr* bandwidth_in
-#endif
- )
+connection receive_data(std::vector<char>& buf, bandwidth_in_ptr* bandwidth_in)
{
if(!socket_set) {
return 0;
@@ -859,7 +837,6 @@
return 0;
}
-#ifdef BANDWIDTH_MONITOR
{
bandwidth_in_ptr temp;
if (!bandwidth_in)
@@ -869,7 +846,6 @@
const int headers = 4;
bandwidth_in->reset(new network::bandwidth_in(buf.size() +
headers));
}
-#endif
int set_res = SDLNet_TCP_AddSocket(socket_set,sock);
@@ -891,7 +867,6 @@
waiting_sockets.insert(result);
return result;
}
-#ifdef BANDWIDTH_MONITOR
struct bandwidth_stats {
int out_packets;
int out_bytes;
@@ -1021,14 +996,7 @@
add_bandwidth_in(type_, len_);
}
-#endif
-void send_file(const std::string& filename, connection connection_num,
-#ifdef BANDWIDTH_MONITOR
- const std::string& packet_type
-#else
- const std::string&
-#endif
- )
+void send_file(const std::string& filename, connection connection_num, const
std::string& packet_type)
{
assert(connection_num > 0);
if(bad_sockets.count(connection_num) || bad_sockets.count(0)) {
@@ -1042,10 +1010,8 @@
return;
}
-#ifdef BANDWIDTH_MONITOR
- const int packet_headers = 5;
+ const int packet_headers = 4;
add_bandwidth_out(packet_type, file_size(filename) + packet_headers);
-#endif
network_worker_pool::queue_file(info->second.sock, filename);
}
@@ -1053,13 +1019,7 @@
//! @todo Note the gzipped parameter should be removed later, we want to send
//! all data gzipped. This can be done once the campaign server is also updated
//! to work with gzipped data.
-size_t send_data(const config& cfg, connection connection_num, const bool
gzipped,
-#ifdef BANDWIDTH_MONITOR
- const std::string& packet_type
-#else
- const std::string&
-#endif
- )
+size_t send_data(const config& cfg, connection connection_num, const bool
gzipped, const std::string& packet_type)
{
DBG_NW << "in send_data()...\n";
@@ -1078,11 +1038,7 @@
for(sockets_list::const_iterator i = sockets.begin();
i != sockets.end(); ++i) {
DBG_NW << "server socket: " << server_socket <<
"\ncurrent socket: " << *i << "\n";
- size = send_data(cfg,*i, gzipped
-#ifdef BANDWIDTH_MONITOR
- , packet_type
-#endif
- );
+ size = send_data(cfg,*i, gzipped, packet_type);
}
return size;
}
@@ -1095,11 +1051,7 @@
}
LOG_NW << "SENDING to: " << connection_num << ": " << cfg;
- return network_worker_pool::queue_data(info->second.sock, cfg, gzipped
-#ifdef BANDWIDTH_MONITOR
- , packet_type
-#endif
- );
+ return network_worker_pool::queue_data(info->second.sock, cfg, gzipped,
packet_type);
}
void send_raw_data(const char* buf, int len, connection connection_num, const
std::string& packet_type)
@@ -1126,10 +1078,8 @@
<< "\tnot found in connection_map. Not sending...\n";
return;
}
-#ifdef BANDWIDTH_MONITOR
- const int packet_headers = 5;
+ const int packet_headers = 4;
add_bandwidth_out(packet_type, len + packet_headers);
-#endif
network_worker_pool::queue_raw_data(info->second.sock, buf, len);
}
@@ -1140,24 +1090,14 @@
}
//! @todo Note the gzipped parameter should be removed later.
-void send_data_all_except(const config& cfg, connection connection_num, const
bool gzipped,
-#ifdef BANDWIDTH_MONITOR
- const std::string& packet_type
-#else
- const std::string&
-#endif
- )
+void send_data_all_except(const config& cfg, connection connection_num, const
bool gzipped, const std::string& packet_type)
{
for(sockets_list::const_iterator i = sockets.begin(); i !=
sockets.end(); ++i) {
if(*i == connection_num) {
continue;
}
- send_data(cfg,*i, gzipped
-#ifdef BANDWIDTH_MONITOR
- , packet_type
-#endif
- );
+ send_data(cfg,*i, gzipped, packet_type);
}
}
Modified: trunk/src/network.hpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/network.hpp?rev=29231&r1=29230&r2=29231&view=diff
==============================================================================
--- trunk/src/network.hpp (original)
+++ trunk/src/network.hpp Wed Sep 3 03:22:52 2008
@@ -20,7 +20,6 @@
/**
* Enable bandwidth stats
**/
-//#define BANDWIDTH_MONITOR
class config;
@@ -128,7 +127,6 @@
//! on the given connection (and presumably then the handling of the error
//! will include closing the connection).
void queue_disconnect(connection connection_num);
-#ifdef BANDWIDTH_MONITOR
std::string get_bandwidth_stats();
std::string get_bandwidth_stats_all();
@@ -139,9 +137,6 @@
struct bandwidth_in {
bandwidth_in(int len) : len_(len), type_("unknown") {}
~bandwidth_in();
-// {
-// network::add_bandwidth_in(type_, len_);
-// }
void set_type(const std::string& type)
{
@@ -155,7 +150,6 @@
typedef boost::shared_ptr<bandwidth_in> bandwidth_in_ptr;
-#endif
//! Function to receive data from either a certain connection,
@@ -165,21 +159,9 @@
//! Returns the connection that data was received from,
//! or 0 if timeout occurred.
//! Throws error if an error occurred.
-connection receive_data(config& cfg, connection connection_num=0, bool*
gzipped = 0
-#ifdef BANDWIDTH_MONITOR
- , bandwidth_in_ptr* b = 0
-#endif
- );
-connection receive_data(config& cfg, connection connection_num, unsigned int
timeout
-#ifdef BANDWIDTH_MONITOR
- , bandwidth_in_ptr* b = 0
-#endif
- );
-connection receive_data(std::vector<char>& buf
-#ifdef BANDWIDTH_MONITOR
- , bandwidth_in_ptr* = 0
-#endif
- );
+connection receive_data(config& cfg, connection connection_num=0, bool*
gzipped = 0, bandwidth_in_ptr* b = 0);
+connection receive_data(config& cfg, connection connection_num, unsigned int
timeout, bandwidth_in_ptr* b = 0);
+connection receive_data(std::vector<char>& buf, bandwidth_in_ptr* = 0);
void send_file(const std::string&, connection, const std::string& packet_type
= "unknown");
Modified: trunk/src/network_worker.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/network_worker.cpp?rev=29231&r1=29230&r2=29231&view=diff
==============================================================================
--- trunk/src/network_worker.cpp (original)
+++ trunk/src/network_worker.cpp Wed Sep 3 03:22:52 2008
@@ -883,11 +883,7 @@
}
}
-TCPsocket get_received_data(TCPsocket sock, config& cfg, bool* gzipped
-#ifdef BANDWIDTH_MONITOR
- ,network::bandwidth_in_ptr& bandwidth_in
-#endif
- )
+TCPsocket get_received_data(TCPsocket sock, config& cfg, bool*
gzipped,network::bandwidth_in_ptr& bandwidth_in)
{
assert(!raw_data_only);
const threading::lock lock_received(*received_mutex);
@@ -918,9 +914,7 @@
if (gzipped)
*gzipped = buf->gzipped;
received_data_queue.erase(itor);
-#ifdef BANDWIDTH_MONITOR
bandwidth_in.reset(new
network::bandwidth_in((*itor)->raw_buffer.size()));
-#endif
delete buf;
return res;
}
@@ -970,11 +964,7 @@
queue_buffer(sock, queued_buf);
}
-size_t queue_data(TCPsocket sock,const config& buf, const bool gzipped
-#ifdef BANDWIDTH_MONITOR
- , const std::string& packet_type
-#endif
- )
+size_t queue_data(TCPsocket sock,const config& buf, const bool gzipped, const
std::string& packet_type)
{
DBG_NW << "queuing data...\n";
@@ -983,9 +973,7 @@
queued_buf->gzipped = gzipped;
const size_t size = queued_buf->stream.str().size();
-#ifdef BANDWIDTH_MONITOR
network::add_bandwidth_out(packet_type, size);
-#endif
queue_buffer(sock, queued_buf);
return size;
}
Modified: trunk/src/network_worker.hpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/network_worker.hpp?rev=29231&r1=29230&r2=29231&view=diff
==============================================================================
--- trunk/src/network_worker.hpp (original)
+++ trunk/src/network_worker.hpp Wed Sep 3 03:22:52 2008
@@ -53,22 +53,14 @@
/** Function to asynchronously received data to the given socket. */
void receive_data(TCPsocket sock);
-TCPsocket get_received_data(TCPsocket sock, config& cfg, bool* gzipped
-#ifdef BANDWIDTH_MONITOR
- , network::bandwidth_in_ptr&
-#endif
- );
+TCPsocket get_received_data(TCPsocket sock, config& cfg, bool* gzipped,
network::bandwidth_in_ptr&);
TCPsocket get_received_data(std::vector<char>& buf);
void queue_file(TCPsocket sock, const std::string&);
void queue_raw_data(TCPsocket sock, const char* buf, int len);
-size_t queue_data(TCPsocket sock, const config& buf, const bool gzipped
-#ifdef BANDWIDTH_MONITOR
- , const std::string& packet_type
-#endif
- );
+size_t queue_data(TCPsocket sock, const config& buf, const bool gzipped, const
std::string& packet_type);
bool is_locked(const TCPsocket sock);
bool close_socket(TCPsocket sock, bool force=false);
TCPsocket detect_error();
Modified: trunk/src/server/server.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/server/server.cpp?rev=29231&r1=29230&r2=29231&view=diff
==============================================================================
--- trunk/src/server/server.cpp (original)
+++ trunk/src/server/server.cpp Wed Sep 3 03:22:52 2008
@@ -634,7 +634,6 @@
clean_user_handler(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)
@@ -643,7 +642,6 @@
LOG_SERVER <<
network::get_bandwidth_stats();
}
-#endif
// send a 'ping' to all players to detect ghosts
DBG_SERVER << "Pinging inactive players.\n" ;
@@ -696,14 +694,8 @@
static int sample_counter = 0;
std::vector<char> buf;
-#ifdef BANDWIDTH_MONITOR
network::bandwidth_in_ptr bandwidth_type;
-#endif
- while ((sock = network::receive_data(buf
-#ifdef BANDWIDTH_MONITOR
- , &bandwidth_type
-#endif
- )) !=
network::null_connection) {
+ while ((sock = network::receive_data(buf,
&bandwidth_type)) != network::null_connection) {
metrics_.service_request();
if(buf.empty()) {
@@ -739,9 +731,7 @@
process_data(sock, data);
-#ifdef BANDWIDTH_MONITOR
bandwidth_type->set_type("command");
-#endif
if(sample) {
const clock_t after_processing =
get_cpu_time(sample);
metrics_.record_sample(data.root().first_child(),
@@ -1208,12 +1198,10 @@
out << "Network stats:\nPending send buffers: "
<< stats.npending_sends << "\nBytes in buffers: "
<< stats.nbytes_pending_sends << "\n";
-#ifdef BANDWIDTH_MONITOR
if (parameters == "all")
out << network::get_bandwidth_stats_all();
else
out << network::get_bandwidth_stats(); // stats from
previuos hour
-#endif
} else if (command == "msg" || command == "lobbymsg") {
if (parameters == "") {
return "You must type a message.";
_______________________________________________
Wesnoth-commits mailing list
[email protected]
https://mail.gna.org/listinfo/wesnoth-commits