diff --git a/src/ebusd/connection.cpp b/src/ebusd/connection.cpp index 2ba605ba..f0d6b2d2 100644 --- a/src/ebusd/connection.cpp +++ b/src/ebusd/connection.cpp @@ -23,7 +23,7 @@ extern LogInstance& L; -int Connection::m_count = -1; +int Connection::m_sum = 0; void Connection::addResult(Message message) { @@ -85,10 +85,10 @@ void* Connection::run() m_data->add(new Message(data, this)); // wait for result - L.log(net, debug, "[%08x] wait for result", getID()); + L.log(net, debug, "[%05d] wait for result", getID()); Message* message = m_result.remove(); - L.log(net, debug, "[%08x] result added", getID()); + L.log(net, debug, "[%05d] result added", getID()); std::string result(message->getData()); if (m_socket->isValid() == true) @@ -104,7 +104,7 @@ void* Connection::run() delete m_socket; m_running = false; - L.log(net, trace, "[%08x] connection closed", getID()); + L.log(net, trace, "[%05d] connection closed", getID()); return NULL; } diff --git a/src/ebusd/connection.h b/src/ebusd/connection.h index 49c0d690..5e9b160c 100644 --- a/src/ebusd/connection.h +++ b/src/ebusd/connection.h @@ -31,9 +31,7 @@ class Connection : public Thread public: Connection(TCPSocket* socket, WQueue* data) - : m_socket(socket), m_data(data), m_running(false) { m_count++; } - - ~Connection() { m_count--; } + : m_socket(socket), m_data(data), m_running(false) { m_sum++; m_id = m_sum;} void addResult(Message message); @@ -41,8 +39,7 @@ public: void stop() const { m_notify.notify(); } bool isRunning() const { return m_running; } - pthread_t getID() { return this->self(); } - int numConnections() const { return m_count; } + int getID() { return m_id; } private: TCPSocket* m_socket; @@ -50,8 +47,9 @@ private: WQueue m_result; Notify m_notify; bool m_running; + int m_id; - static int m_count; + static int m_sum; }; diff --git a/src/ebusd/network.cpp b/src/ebusd/network.cpp index f054d14e..168ddd2e 100644 --- a/src/ebusd/network.cpp +++ b/src/ebusd/network.cpp @@ -107,7 +107,7 @@ void* Network::run() connection->start("connection"); m_connections.push_back(connection); - L.log(net, trace, "[%08x] connection opened %s", connection->getID(), socket->getIP().c_str()); + L.log(net, trace, "[%05d] connection opened %s", connection->getID(), socket->getIP().c_str()); } }