Skip to content

Commit 31b6488

Browse files
authored
Print the task name when socket open/recv fails (#4434)
* Log task name of socket that failed to open port * Give failed to recv the same treatment * Format my changes
1 parent 62dd744 commit 31b6488

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

Drv/Ip/SocketComponentHelper.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,8 @@ void SocketComponentHelper::readLoop() {
220220
status = this->recv(data, size);
221221
if ((status != SOCK_SUCCESS) && (status != SOCK_INTERRUPTED_TRY_AGAIN) &&
222222
(status != SOCK_NO_DATA_AVAILABLE)) {
223-
Fw::Logger::log("[WARNING] Failed to recv from port with status %d and errno %d\n", status, errno);
223+
Fw::Logger::log("[WARNING] %s failed to recv from port with status %d and errno %d\n",
224+
this->m_task.getName().toChar(), status, errno);
224225
this->close();
225226
buffer.setSize(0);
226227
} else {
@@ -297,7 +298,8 @@ void SocketComponentHelper::reconnectLoop() {
297298
// Reopen Case 3: Keep trying to reconnect - NO reconnect
298299
// state change
299300
else {
300-
Fw::Logger::log("[WARNING] Failed to open port with status %d and errno %d\n", status, errno);
301+
Fw::Logger::log("[WARNING] %s failed to open port with status %d and errno %d\n",
302+
this->m_task.getName().toChar(), status, errno);
301303
(void)Os::Task::delay(SOCKET_RETRY_INTERVAL);
302304
}
303305
} else {

Os/Task.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,11 @@ bool Task::isCooperative() {
174174
return this->m_delegate.isCooperative();
175175
}
176176

177+
TaskString Task::getName() {
178+
Os::ScopeLock lock(this->m_lock);
179+
return this->m_name;
180+
}
181+
177182
FwTaskPriorityType Task::getPriority() {
178183
Os::ScopeLock lock(this->m_lock);
179184
return this->m_priority;

Os/Task.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -346,6 +346,9 @@ class Task final : public TaskInterface {
346346
//! \return true if cooperative, false otherwise
347347
bool isCooperative() override;
348348

349+
//! \brief get the task name
350+
TaskString getName();
351+
349352
//! \brief get the task priority
350353
FwTaskPriorityType getPriority();
351354

0 commit comments

Comments
 (0)