written = write(fd, (char*) pData, remain);
if (written < 0)
{
- SysLogException(NID_IO, E_SYSTEM, "[E_SYSTEM] Failed to send a request: %d, %s", errno, strerror(errno));
-
ReleaseFd(fd);
+
+ if (errno == EAGAIN)
+ {
+ SysLogException(NID_IO, E_RESOURCE_UNAVAILABLE, "[E_RESOURCE_UNAVAILABLE] The socket buffer is full.");
+ return E_RESOURCE_UNAVAILABLE;
+ }
+ else if (errno == EPIPE)
+ {
+ SysLogException(NID_IO, E_INVALID_CONNECTION, "[E_INVALID_CONNECTION] The socket connection is closed.");
+ return E_INVALID_CONNECTION;
+ }
+
+ SysLogException(NID_IO, E_SYSTEM, "[E_SYSTEM] Failed to send a request: %d, %s", errno, strerror(errno));
return E_SYSTEM;
}
written = write(fd, (char*) pData, remain);
if (written < 0)
{
- SysLogException(NID_IO, E_SYSTEM, "[E_SYSTEM] Failed to send a request: %d, %s", errno, strerror(errno));
-
ReleaseFd(fd);
+
+ if (errno == EAGAIN)
+ {
+ SysLogException(NID_IO, E_RESOURCE_UNAVAILABLE, "[E_RESOURCE_UNAVAILABLE] The socket buffer is full.");
+ return E_RESOURCE_UNAVAILABLE;
+ }
+ else if (errno == EPIPE)
+ {
+ SysLogException(NID_IO, E_INVALID_CONNECTION, "[E_INVALID_CONNECTION] The socket connection is closed.");
+ return E_INVALID_CONNECTION;
+ }
+
+ SysLogException(NID_IO, E_SYSTEM, "[E_SYSTEM] Failed to send a request: %d, %s", errno, strerror(errno));
return E_SYSTEM;
}
}
SysLogException(NID_IO, E_SYSTEM, "[E_SYSTEM] Failed to poll (%d, %s).", errno, strerror(errno));
+
+ ReleaseFd(fd);
return E_SYSTEM;
}
if (pEndOfMessage)
{
pReply = new (std::nothrow) IPC::Message(message.data(), pEndOfMessage - message.data());
- SysTryReturnResult(NID_IO, pReply != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
+ if (pReply == null)
+ {
+ SysLogException(NID_IO, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+ ReleaseFd(fd);
+ return E_OUT_OF_MEMORY;
+ }
+
break;
}
}