From c169dbdd1fc14f66890dcb6fba7ecf543067875d Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Tue, 14 Jan 2014 01:08:04 +0300 Subject: Use thread safe logging in threads. --- src/net/download.cpp | 4 ++-- src/net/ea/network.cpp | 16 ++++++++-------- src/net/sdltcpnet.cpp | 4 ++-- 3 files changed, 12 insertions(+), 12 deletions(-) (limited to 'src') diff --git a/src/net/download.cpp b/src/net/download.cpp index e9b6dd6d7..d986fa232 100644 --- a/src/net/download.cpp +++ b/src/net/download.cpp @@ -302,7 +302,7 @@ int Download::downloadThread(void *ptr) { if (d->mError) { - logger->log("curl error %d: %s host: %s", + logger->log_r("curl error %d: %s host: %s", res, d->mError, d->mUrl.c_str()); } break; @@ -347,7 +347,7 @@ int Download::downloadThread(void *ptr) // Remove the corrupted file ::remove(d->mFileName.c_str()); - logger->log("Checksum for file %s failed: (%lx/%lx)", + logger->log_r("Checksum for file %s failed: (%lx/%lx)", d->mFileName.c_str(), adler, d->mAdler); attempts++; diff --git a/src/net/ea/network.cpp b/src/net/ea/network.cpp index 4ca79b87e..c5ed9de57 100644 --- a/src/net/ea/network.cpp +++ b/src/net/ea/network.cpp @@ -201,10 +201,10 @@ bool Network::realConnect() _("Unable to resolve host \"")).append( mServer.hostname).append("\"."); setError(errorMessage); - logger->log("TcpNet::ResolveHost: %s", errorMessage.c_str()); + logger->log_r("TcpNet::ResolveHost: %s", errorMessage.c_str()); return false; } - logger->log("using alt host name: %s", mServer.althostname.c_str()); + logger->log_r("using alt host name: %s", mServer.althostname.c_str()); } mState = CONNECTING; @@ -212,12 +212,12 @@ bool Network::realConnect() mSocket = TcpNet::open(&ipAddress); if (!mSocket) { - logger->log("Error in TcpNet::open(): %s", TcpNet::getError()); + logger->log_r("Error in TcpNet::open(): %s", TcpNet::getError()); setError(TcpNet::getError()); return false; } - logger->log("Network::Started session with %s:%i", + logger->log_r("Network::Started session with %s:%i", ipToString(ipAddress.host), ipAddress.port); mState = CONNECTED; @@ -248,7 +248,7 @@ void Network::receive() switch (numReady) { case -1: - logger->log1("Error: TcpNet::checkSockets"); + logger->log_r("Error: TcpNet::checkSockets"); break; // FALLTHROUGH case 0: @@ -272,7 +272,7 @@ void Network::receive() { // We got disconnected mState = IDLE; - logger->log1("Disconnected."); + logger->log_r("Disconnected."); } else if (ret < 0) { @@ -315,14 +315,14 @@ void Network::receive() } if (TcpNet::delSocket(set, mSocket) == -1) - logger->log("Error in TcpNet::delSocket(): %s", TcpNet::getError()); + logger->log_r("Error in TcpNet::delSocket(): %s", TcpNet::getError()); TcpNet::freeSocketSet(set); } void Network::setError(const std::string &error) { - logger->log("Network error: %s", error.c_str()); + logger->log_r("Network error: %s", error.c_str()); mError = error; mState = NET_ERROR; } diff --git a/src/net/sdltcpnet.cpp b/src/net/sdltcpnet.cpp index c07ba569b..7530e0f53 100644 --- a/src/net/sdltcpnet.cpp +++ b/src/net/sdltcpnet.cpp @@ -106,14 +106,14 @@ TcpNet::Socket TcpNet::open(IPaddress *const ip) if (setsockopt(hack->channel, IPPROTO_TCP, TCP_THIN_LINEAR_TIMEOUTS, &val, sizeof(val))) { - logger->log1("error on set TCP_THIN_LINEAR_TIMEOUTS"); + logger->log_r("error on set TCP_THIN_LINEAR_TIMEOUTS"); } #endif #ifdef TCP_THIN_DUPACK if (setsockopt(hack->channel, IPPROTO_TCP, TCP_THIN_DUPACK, &val, sizeof(val))) { - logger->log1("error on set TCP_THIN_DUPACK"); + logger->log_r("error on set TCP_THIN_DUPACK"); } #endif } -- cgit v1.2.3-70-g09d2