aboutsummaryrefslogtreecommitdiff
path: root/contrib/epee/src
diff options
context:
space:
mode:
authorRiccardo Spagni <ric@spagni.net>2017-12-25 21:17:52 +0200
committerRiccardo Spagni <ric@spagni.net>2017-12-25 21:17:52 +0200
commit2b00899bb28e09f0c44813689acc0add73832215 (patch)
tree7db8c261c5b1014f5451f157f29b37f58409bc89 /contrib/epee/src
parentMerge pull request #2918 (diff)
parentnetwork_throttle: fix ineffective locking (diff)
downloadmonero-2b00899bb28e09f0c44813689acc0add73832215.tar.xz
Merge pull request #2920
bd5cce07 network_throttle: fix ineffective locking (moneromooo-monero) e0a61299 network_throttle: remove unused xxx static member (moneromooo-monero) 24f584d9 cryptonote_core: remove unused functions with off by one bugs (moneromooo-monero) b1634aa3 blockchain: don't leave dangling pointers in this (moneromooo-monero) 8e60b81c cryptonote_core: fix db leak on error (moneromooo-monero) 213e326c abstract_tcp_server2: log init_server errors as fatal (moneromooo-monero) b51dc566 use const refs in for loops for non tiny types (moneromooo-monero) f0568ca6 net_parse_helpers: fix regex error checking (moneromooo-monero) b49ddc76 check accessing an element past the end of a container (moneromooo-monero) 2305bf26 check return value for generate_key_derivation and derive_public_key (moneromooo-monero) a4240d9f catch const exceptions (moneromooo-monero) 45a1c4c0 add empty container sanity checks when using front() and back() (moneromooo-monero) 56fa6ce1 tests: fix a buffer overread in a unit test (moneromooo-monero) b4524892 rpc: guard against json parsing a non object (moneromooo-monero) c2ed8618 easylogging++: avoid buffer underflow (moneromooo-monero) 187a6ab2 epee: trap failure to parse URI from request (moneromooo-monero) 061789b5 checkpoints: trap failure to load JSON checkpoints (moneromooo-monero) ba2fefb9 checkpoints: pass std::string by const ref, not const value (moneromooo-monero) 38c8f4e0 mlog: terminate a string at last char, just in case (moneromooo-monero) d753d716 fix a few leaks by throwing objects, not newed pointers to objects (moneromooo-monero) fe568db8 p2p: use size_t for arbitrary counters instead of uint8_t (moneromooo-monero) 46d6fa35 cryptonote_protocol: sanity check chain hashes from peer (moneromooo-monero) 25584f86 cryptonote_protocol: print peer versions when unexpected (moneromooo-monero) 490a5d41 rpc: do not try to use an invalid txid in relay_tx (moneromooo-monero)
Diffstat (limited to 'contrib/epee/src')
-rw-r--r--contrib/epee/src/mlog.cpp1
-rw-r--r--contrib/epee/src/network_throttle-detail.cpp8
-rw-r--r--contrib/epee/src/network_throttle.cpp3
3 files changed, 6 insertions, 6 deletions
diff --git a/contrib/epee/src/mlog.cpp b/contrib/epee/src/mlog.cpp
index a30efbc6a..5b9472006 100644
--- a/contrib/epee/src/mlog.cpp
+++ b/contrib/epee/src/mlog.cpp
@@ -59,6 +59,7 @@ static std::string generate_log_filename(const char *base)
strcpy(tmp, "unknown");
else
strftime(tmp, sizeof(tmp), "%Y-%m-%d-%H-%M-%S", &tm);
+ tmp[sizeof(tmp) - 1] = 0;
filename += "-";
filename += tmp;
return filename;
diff --git a/contrib/epee/src/network_throttle-detail.cpp b/contrib/epee/src/network_throttle-detail.cpp
index 317dde8e0..ed6bc07ed 100644
--- a/contrib/epee/src/network_throttle-detail.cpp
+++ b/contrib/epee/src/network_throttle-detail.cpp
@@ -231,8 +231,10 @@ network_time_seconds network_throttle::get_sleep_time_after_tick(size_t packet_s
}
void network_throttle::logger_handle_net(const std::string &filename, double time, size_t size) {
- boost::mutex mutex;
- mutex.lock(); {
+ static boost::mutex mutex;
+
+ boost::lock_guard<boost::mutex> lock(mutex);
+ {
std::fstream file;
file.open(filename.c_str(), std::ios::app | std::ios::out );
file.precision(6);
@@ -240,7 +242,7 @@ void network_throttle::logger_handle_net(const std::string &filename, double tim
_warn("Can't open file " << filename);
file << static_cast<int>(time) << " " << static_cast<double>(size/1024) << "\n";
file.close();
- } mutex.unlock();
+ }
}
// fine tune this to decide about sending speed:
diff --git a/contrib/epee/src/network_throttle.cpp b/contrib/epee/src/network_throttle.cpp
index afacc3e96..dd1640a2e 100644
--- a/contrib/epee/src/network_throttle.cpp
+++ b/contrib/epee/src/network_throttle.cpp
@@ -71,9 +71,6 @@ boost::mutex network_throttle_manager::m_lock_get_global_throttle_in;
boost::mutex network_throttle_manager::m_lock_get_global_throttle_inreq;
boost::mutex network_throttle_manager::m_lock_get_global_throttle_out;
-int network_throttle_manager::xxx;
-
-
// ================================================================================================
// methods:
i_network_throttle & network_throttle_manager::get_global_throttle_in() {