diff --git a/src/buffer.cpp b/src/buffer.cpp index 27968fcc..efd7d35c 100644 --- a/src/buffer.cpp +++ b/src/buffer.cpp @@ -48,7 +48,9 @@ namespace Buffer{ void handleUser(void * v_usr){ user * usr = (user*)v_usr; + #if DEBUG >= 4 std::cerr << "Thread launched for user " << usr->MyStr << ", socket number " << usr->S.getSocket() << std::endl; + #endif usr->myRing = thisStream->getRing(); usr->S.Send(thisStream->getHeader()); @@ -89,7 +91,6 @@ namespace Buffer{ } usr->Disconnect("Socket closed."); thisStream->cleanUsers(); - std::cerr << "User " << usr->MyStr << " disconnected, socket number " << usr->S.getSocket() << std::endl; } /// Loop reading DTSC data from stdin and processing it at the correct speed. diff --git a/src/buffer_stream.cpp b/src/buffer_stream.cpp index 4b506a34..cd662733 100644 --- a/src/buffer_stream.cpp +++ b/src/buffer_stream.cpp @@ -128,14 +128,18 @@ void Buffer::Stream::saveStats(std::string username, Stats & stats){ /// Stores final statistics. void Buffer::Stream::clearStats(std::string username, Stats & stats, std::string reason){ stats_mutex.lock(); - Storage["curr"].removeMember(username); + if (Storage["curr"].isMember(username)){ + Storage["curr"].removeMember(username); + #if DEBUG >= 4 + std::cout << "Disconnected user " << username << ": " << reason << ". " << stats.connector << " transferred " << stats.up << " up and " << stats.down << " down in " << stats.conntime << " seconds to " << stats.host << std::endl; + #endif + } Storage["log"][username]["connector"] = stats.connector; Storage["log"][username]["up"] = stats.up; Storage["log"][username]["down"] = stats.down; Storage["log"][username]["conntime"] = stats.conntime; Storage["log"][username]["host"] = stats.host; Storage["log"][username]["start"] = (unsigned int)time(0) - stats.conntime; - std::cout << "Disconnected user " << username << ": " << reason << ". " << stats.connector << " transferred " << stats.up << " up and " << stats.down << " down in " << stats.conntime << " seconds to " << stats.host << std::endl; stats_mutex.unlock(); cleanUsers(); } diff --git a/src/buffer_user.cpp b/src/buffer_user.cpp index 75f3a9e4..b26cf6d5 100644 --- a/src/buffer_user.cpp +++ b/src/buffer_user.cpp @@ -21,7 +21,6 @@ Buffer::user::user(Socket::Connection fd){ currsend = 0; myRing = 0; Thread = 0; - std::cout << "User " << MyNum << " connected" << std::endl; }//constructor /// Drops held DTSC::Ring class, if one is held. @@ -65,7 +64,7 @@ void Buffer::user::Send(){ }//still waiting for next buffer? if (myRing->starved){ //if corrupt data, warn and get new DTSC::Ring - std::cout << "Warning: User was send corrupt video data and send to the next keyframe!" << std::endl; + std::cout << "Warning: User " << MyNum << " was send corrupt video data and send to the next keyframe!" << std::endl; Stream::get()->dropRing(myRing); myRing = Stream::get()->getRing(); return; diff --git a/src/conn_http.cpp b/src/conn_http.cpp index 9b4f19a7..be32ee2e 100644 --- a/src/conn_http.cpp +++ b/src/conn_http.cpp @@ -59,21 +59,17 @@ namespace Connector_HTTP{ void Timeout_Thread(void * n){ n = 0;//prevent unused variable warning tthread::lock_guard guard(timeout_mutex); - std::cout << "Started timeout thread" << std::endl; while (true){ { tthread::lock_guard guard(conn_mutex); if (connconn.empty()){ - std::cout << "No more connections" << std::endl; return; } - std::cout << "Currently " << connconn.size() << " active connections" << std::endl; std::map::iterator it; for (it = connconn.begin(); it != connconn.end(); it++){ if (!it->second->conn->connected() || it->second->lastuse++ > 15){ if (it->second->in_use.try_lock()){ it->second->in_use.unlock(); - std::cout << "Murdered one" << std::endl; delete it->second; connconn.erase(it); it = connconn.begin();//get a valid iterator @@ -273,7 +269,6 @@ namespace Connector_HTTP{ HTTP::Parser Client; while (conn->connected()){ if (conn->spool()){ - std::cout << "Data: " << conn->Received() << std::endl; if (Client.Read(conn->Received())){ std::string handler = getHTTPType(Client); #if DEBUG >= 4 @@ -289,7 +284,6 @@ namespace Connector_HTTP{ Handle_Through_Connector(Client, conn, handler); } Client.Clean(); //clean for any possible next requests - std::cout << "Request handled" << std::endl; }else{ #if DEBUG >= 3 fprintf(stderr, "Could not parse the following:\n%s\n", conn->Received().c_str()); diff --git a/src/conn_http_dynamic.cpp b/src/conn_http_dynamic.cpp index 899ea77f..488deb05 100644 --- a/src/conn_http_dynamic.cpp +++ b/src/conn_http_dynamic.cpp @@ -68,7 +68,9 @@ namespace Connector_HTTP{ std::string Result; Result.append((char*)abst.GetBoxedData(), (int)abst.GetBoxedDataSize()); + #if DEBUG >= 4 std::cout << "Sending bootstrap:" << std::endl << abst.toPrettyString(0) << std::endl; + #endif return Base64::encode(Result); } @@ -101,7 +103,9 @@ namespace Connector_HTTP{ "\n" "\n"; } + #if DEBUG >= 4 std::cerr << "Sending this manifest:" << std::endl << Result << std::endl; + #endif return Result; }//BuildManifest