wsd: improved socket logging
More consistent logging of the socket FD. Change-Id: Iee24ad4eb067969abfc06f78a768563351d264c7 Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
This commit is contained in:
parent
f43adb76ae
commit
3b9cc13b7a
2 changed files with 18 additions and 14 deletions
|
@ -1066,8 +1066,10 @@ public:
|
|||
return false;
|
||||
}
|
||||
|
||||
assert(_socket.lock() && "Connect must set the _socket member.");
|
||||
LOG_TRC("Connected");
|
||||
LOG_ASSERT_MSG(_socket.lock(), "Connect must set the _socket member.");
|
||||
LOG_ASSERT_MSG(_socket.lock()->getFD() == socket->getFD(),
|
||||
"Socket FD's mismatch after connect().");
|
||||
LOG_TRC('#' << socket->getFD() << ": Connected");
|
||||
poll.insertNewSocket(socket);
|
||||
}
|
||||
else
|
||||
|
@ -1244,23 +1246,24 @@ private:
|
|||
if (socket)
|
||||
{
|
||||
Buffer& out = socket->getOutBuffer();
|
||||
LOG_TRC("performWrites: " << out.size() << " bytes, capacity: " << capacity);
|
||||
LOG_TRC('#' << socket->getFD() << ": performWrites: " << out.size()
|
||||
<< " bytes, capacity: " << capacity);
|
||||
|
||||
if (!socket->send(_request))
|
||||
{
|
||||
LOG_ERR('#' << socket->getFD() << " Error while writing to socket.");
|
||||
LOG_ERR('#' << socket->getFD() << ": Error while writing to socket.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void onDisconnect() override
|
||||
{
|
||||
LOG_TRC("onDisconnect");
|
||||
|
||||
// Make sure the socket is disconnected and released.
|
||||
std::shared_ptr<StreamSocket> socket = _socket.lock();
|
||||
if (socket)
|
||||
{
|
||||
LOG_TRC('#' << socket->getFD() << ": onDisconnect");
|
||||
|
||||
socket->shutdown(); // Flag for shutdown for housekeeping in SocketPoll.
|
||||
socket->closeConnection(); // Immediately disconnect.
|
||||
_socket.reset();
|
||||
|
|
|
@ -81,7 +81,8 @@ bool StreamSocket::simulateSocketError(bool read)
|
|||
{
|
||||
if ((socketErrorCount++ % 7) == 0)
|
||||
{
|
||||
LOG_TRC("Simulating socket error during " << (read ? "read." : "write."));
|
||||
LOG_TRC('#' << getFD() << ": Simulating socket error during "
|
||||
<< (read ? "read." : "write."));
|
||||
errno = EAGAIN;
|
||||
return true;
|
||||
}
|
||||
|
@ -432,9 +433,9 @@ int SocketPoll::poll(int64_t timeoutMaxMicroS)
|
|||
std::vector<int> toErase;
|
||||
|
||||
size_t i = _pollStartIndex;
|
||||
LOG_TRC("Starting handling poll results of "
|
||||
<< _name << " #" << _pollFds[i].fd << " at index " << _pollStartIndex << " (of "
|
||||
<< size << "): " << std::hex << _pollFds[i].revents << std::dec);
|
||||
LOG_TRC('#' << _pollFds[i].fd << ": Starting handling poll results of " << _name
|
||||
<< " at index " << _pollStartIndex << " (of " << size << "): " << std::hex
|
||||
<< _pollFds[i].revents << std::dec);
|
||||
|
||||
size_t previ = size;
|
||||
while (previ != _pollStartIndex)
|
||||
|
@ -447,7 +448,7 @@ int SocketPoll::poll(int64_t timeoutMaxMicroS)
|
|||
}
|
||||
catch (const std::exception& exc)
|
||||
{
|
||||
LOG_ERR('#' << _pollFds[i].fd << " Error while handling poll at " << i << " in "
|
||||
LOG_ERR('#' << _pollFds[i].fd << ": Error while handling poll at " << i << " in "
|
||||
<< _name << ": " << exc.what());
|
||||
disposition.setClosed();
|
||||
rc = -1;
|
||||
|
@ -467,10 +468,10 @@ int SocketPoll::poll(int64_t timeoutMaxMicroS)
|
|||
if (!toErase.empty())
|
||||
{
|
||||
std::sort(toErase.begin(), toErase.end(), [](int a, int b) { return a > b; });
|
||||
for (int eraseIndex : toErase)
|
||||
for (const int eraseIndex : toErase)
|
||||
{
|
||||
LOG_TRC("Removing socket #" << _pollFds[eraseIndex].fd << " (at " << eraseIndex
|
||||
<< " of " << _pollSockets.size() << ") from " << _name);
|
||||
LOG_TRC('#' << _pollFds[eraseIndex].fd << ": Removing socket (at " << eraseIndex
|
||||
<< " of " << _pollSockets.size() << ") from " << _name);
|
||||
_pollSockets.erase(_pollSockets.begin() + eraseIndex);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue