/**
* Error code to hold the errno(Timeout, Destination unreachable, etc) when send/recv fails.
* Main purpose is to hold the reason for connection drop when keep-alive is in use.
+ * To indicate normal disconnection, 0 will be assigned.
*/
static int g_lastErrorCode;
{
g_lastErrorCode = errno;
OIC_LOG_V(DEBUG, TAG, "Set g_lastErrorCode to %s", strerror(g_lastErrorCode));
- OIC_LOG_V(ERROR, TAG, "recv failed %s", strerror(errno));
+ OIC_LOG_V(ERROR, TAG, "recv failed %s", strerror(g_lastErrorCode));
res = CA_RECEIVE_FAILED;
}
else if (0 == len)
{
+ g_lastErrorCode = 0;
+ OIC_LOG(DEBUG, TAG, "Set g_lastErrorCode to 0");
OIC_LOG(INFO, TAG, "Received disconnect from peer. Close connection");
svritem->state = DISCONNECTED;
res = CA_DESTINATION_DISCONNECTED;
{
g_lastErrorCode = errno;
OIC_LOG_V(DEBUG, TAG, "Set g_lastErrorCode to %s", strerror(g_lastErrorCode));
- OIC_LOG_V(ERROR, TAG, "recv failed %s", strerror(errno));
+ OIC_LOG_V(ERROR, TAG, "recv failed %s", strerror(g_lastErrorCode));
res = CA_RECEIVE_FAILED;
}
else if (0 == len)
{
+ g_lastErrorCode = 0;
+ OIC_LOG_V(DEBUG, TAG, "Set g_lastErrorCode to 0");
OIC_LOG(INFO, TAG, "Received disconnect from peer. Close connection");
res = CA_DESTINATION_DISCONNECTED;
}
{
g_lastErrorCode = errno;
OIC_LOG_V(DEBUG, TAG, "Set g_lastErrorCode to %s", strerror(g_lastErrorCode));
- if (EWOULDBLOCK != errno && EAGAIN != errno)
+ if (EWOULDBLOCK != g_lastErrorCode && EAGAIN != g_lastErrorCode)
{
- OIC_LOG_V(ERROR, TAG, "unicast ipv4tcp sendTo failed: %s", strerror(errno));
+ OIC_LOG_V(ERROR, TAG, "unicast ipv4tcp sendTo failed: %s", strerror(g_lastErrorCode));
CALogSendStateInfo(endpoint->adapter, endpoint->addr, endpoint->port,
- len, false, strerror(errno));
+ len, false, strerror(g_lastErrorCode));
return len;
}