Fix some compilation problems due to unused variable.
Send const std::string by reference instead of a copy.
This commit is contained in:
parent
181600e48c
commit
16a7a99749
2 changed files with 35 additions and 19 deletions
|
@ -917,7 +917,7 @@ hour_stats_vector hour_stats(24);
|
|||
|
||||
|
||||
|
||||
static bandwidth_map::iterator add_bandwidth_entry(const std::string packet_type)
|
||||
static bandwidth_map::iterator add_bandwidth_entry(const std::string& packet_type)
|
||||
{
|
||||
time_t now = time(0);
|
||||
struct tm * timeinfo = localtime(&now);
|
||||
|
@ -1002,14 +1002,14 @@ std::string get_bandwidth_stats(int hour)
|
|||
return ss.str();
|
||||
}
|
||||
|
||||
void add_bandwidth_out(const std::string packet_type, size_t len)
|
||||
void add_bandwidth_out(const std::string& packet_type, size_t len)
|
||||
{
|
||||
bandwidth_map::iterator itor = add_bandwidth_entry(packet_type);
|
||||
itor->second.out_bytes += len;
|
||||
++(itor->second.out_packets);
|
||||
}
|
||||
|
||||
void add_bandwidth_in(const std::string packet_type, size_t len)
|
||||
void add_bandwidth_in(const std::string& packet_type, size_t len)
|
||||
{
|
||||
bandwidth_map::iterator itor = add_bandwidth_entry(packet_type);
|
||||
itor->second.in_bytes += len;
|
||||
|
@ -1022,8 +1022,13 @@ void add_bandwidth_in(const std::string packet_type, size_t len)
|
|||
}
|
||||
|
||||
#endif
|
||||
void send_file(const std::string& filename, connection connection_num, const std::string packet_type
|
||||
)
|
||||
void send_file(const std::string& filename, connection connection_num,
|
||||
#ifdef BANDWIDTH_MONITOR
|
||||
const std::string& packet_type
|
||||
#else
|
||||
const std::string&
|
||||
#endif
|
||||
)
|
||||
{
|
||||
assert(connection_num > 0);
|
||||
if(bad_sockets.count(connection_num) || bad_sockets.count(0)) {
|
||||
|
@ -1048,7 +1053,13 @@ void send_file(const std::string& filename, connection connection_num, const std
|
|||
//! @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, const std::string packet_type)
|
||||
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
|
||||
)
|
||||
{
|
||||
DBG_NW << "in send_data()...\n";
|
||||
|
||||
|
@ -1091,8 +1102,7 @@ size_t send_data(const config& cfg, connection connection_num, const bool gzippe
|
|||
);
|
||||
}
|
||||
|
||||
void send_raw_data(const char* buf, int len, connection connection_num, const std::string packet_type
|
||||
)
|
||||
void send_raw_data(const char* buf, int len, connection connection_num, const std::string& packet_type)
|
||||
{
|
||||
if(len == 0) {
|
||||
return;
|
||||
|
@ -1105,8 +1115,7 @@ void send_raw_data(const char* buf, int len, connection connection_num, const st
|
|||
if(!connection_num) {
|
||||
for(sockets_list::const_iterator i = sockets.begin();
|
||||
i != sockets.end(); ++i) {
|
||||
send_raw_data(buf, len, connection_num, packet_type
|
||||
);
|
||||
send_raw_data(buf, len, connection_num, packet_type);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
@ -1131,8 +1140,13 @@ void process_send_queue(connection, size_t)
|
|||
}
|
||||
|
||||
//! @todo Note the gzipped parameter should be removed later.
|
||||
void send_data_all_except(const config& cfg, connection connection_num, const bool gzipped, const std::string packet_type
|
||||
)
|
||||
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
|
||||
)
|
||||
{
|
||||
for(sockets_list::const_iterator i = sockets.begin(); i != sockets.end(); ++i) {
|
||||
if(*i == connection_num) {
|
||||
|
|
|
@ -134,8 +134,8 @@ std::string get_bandwidth_stats();
|
|||
std::string get_bandwidth_stats_all();
|
||||
std::string get_bandwidth_stats(int hour);
|
||||
|
||||
void add_bandwidth_out(const std::string packet_type, size_t len);
|
||||
void add_bandwidth_in(const std::string packet_type, size_t len);
|
||||
void add_bandwidth_out(const std::string& packet_type, size_t len);
|
||||
void add_bandwidth_in(const std::string& packet_type, size_t len);
|
||||
struct bandwidth_in {
|
||||
bandwidth_in(int len) : len_(len), type_("unknown") {}
|
||||
~bandwidth_in();
|
||||
|
@ -181,14 +181,16 @@ connection receive_data(std::vector<char>& buf
|
|||
#endif
|
||||
);
|
||||
|
||||
void send_file(const std::string&, connection, const std::string packet_type = "unknown");
|
||||
void send_file(const std::string&, connection, const std::string& packet_type = "unknown");
|
||||
|
||||
//! Function to send data down a given connection,
|
||||
//! or broadcast to all peers if connection_num is 0.
|
||||
//! Throws error.
|
||||
size_t send_data(const config& cfg, connection connection_num /*= 0*/, const bool gzipped, const std::string packet_type = "unknown");
|
||||
size_t send_data(const config& cfg, connection connection_num /*= 0*/,
|
||||
const bool gzipped, const std::string& packet_type = "unknown");
|
||||
|
||||
void send_raw_data(const char* buf, int len, connection connection_num, const std::string packet_type = "unknown");
|
||||
void send_raw_data(const char* buf, int len, connection connection_num,
|
||||
const std::string& packet_type = "unknown");
|
||||
|
||||
//! Function to send any data that is in a connection's send_queue,
|
||||
//! up to a maximum of 'max_size' bytes --
|
||||
|
@ -196,8 +198,8 @@ void send_raw_data(const char* buf, int len, connection connection_num, const st
|
|||
void process_send_queue(connection connection_num=0, size_t max_size=0);
|
||||
|
||||
//! Function to send data to all peers except 'connection_num'.
|
||||
void send_data_all_except(const config& cfg, connection connection_num, const bool gzipped, const std::string packet_type = "unknown"
|
||||
);
|
||||
void send_data_all_except(const config& cfg, connection connection_num,
|
||||
const bool gzipped, const std::string& packet_type = "unknown");
|
||||
|
||||
//! Function to get the remote ip address of a socket.
|
||||
std::string ip_address(connection connection_num);
|
||||
|
|
Loading…
Add table
Reference in a new issue