From 9328ef4f9f1d2a4646f492a0c5279027ee07bf55 Mon Sep 17 00:00:00 2001 From: Sunwook Bae Date: Mon, 3 Jun 2013 19:58:10 +0900 Subject: [PATCH] Add an E_RESOURCE_UNAVAILABLE in IPC Change-Id: Ia992616673ab933fe46367d85e721637754745f1 Signed-off-by: Sunwook Bae --- src/io/FIo_IpcClient.cpp | 20 ++++++++++++++++---- src/io/inc/FIo_IpcClient.h | 1 + src/server/inc/FIo_IpcServer.h | 5 +++-- src/server/io/FIo_IpcServer.cpp | 13 +++++++++---- 4 files changed, 29 insertions(+), 10 deletions(-) diff --git a/src/io/FIo_IpcClient.cpp b/src/io/FIo_IpcClient.cpp index 6e1061f..70a77be 100644 --- a/src/io/FIo_IpcClient.cpp +++ b/src/io/FIo_IpcClient.cpp @@ -493,9 +493,15 @@ _IpcClient::SendAsync(IPC::Message* pMessage) 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; + } + + SysLogException(NID_IO, E_SYSTEM, "[E_SYSTEM] Failed to send a request: %d, %s", errno, strerror(errno)); return E_SYSTEM; } @@ -543,9 +549,15 @@ _IpcClient::SendSync(IPC::Message* pMessage) 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; + } + + SysLogException(NID_IO, E_SYSTEM, "[E_SYSTEM] Failed to send a request: %d, %s", errno, strerror(errno)); return E_SYSTEM; } diff --git a/src/io/inc/FIo_IpcClient.h b/src/io/inc/FIo_IpcClient.h index 1cbd394..7616838 100644 --- a/src/io/inc/FIo_IpcClient.h +++ b/src/io/inc/FIo_IpcClient.h @@ -103,6 +103,7 @@ public: * @param[in] message The message to send * @exception E_SUCCESS The method was successful. * @exception E_INVALID_STATE The instance is in an invalid state. + * @exception E_RESOURCE_UNAVAILABLE The socket buffer is full. * @exception E_OUT_OF_MEMORY Insufficient memory. * @exception E_SYSTEM A system error occurred. * diff --git a/src/server/inc/FIo_IpcServer.h b/src/server/inc/FIo_IpcServer.h index bd90760..4084c58 100644 --- a/src/server/inc/FIo_IpcServer.h +++ b/src/server/inc/FIo_IpcServer.h @@ -123,6 +123,7 @@ public: * @exception E_SUCCESS The method was successful. * @exception E_INVALID_ARG The message is synchronous. * @exception E_INVALID_OPERATION The client didn't set a listener. + * @exception E_RESOURCE_UNAVAILABLE The socket buffer is full. * @exception E_OUT_OF_MEMORY Insufficient memory. * @exception E_SYSTEM A system error occurred. * @@ -130,10 +131,10 @@ public: */ result SendResponse(int clientId, const IPC::Message& message); - result Start(void); - result SendResponse(int clientId, IPC::Message* pMessage); + result Start(void); + bool Send(IPC::Message* msg); private: diff --git a/src/server/io/FIo_IpcServer.cpp b/src/server/io/FIo_IpcServer.cpp index e2da083..6b5f53c 100644 --- a/src/server/io/FIo_IpcServer.cpp +++ b/src/server/io/FIo_IpcServer.cpp @@ -726,8 +726,11 @@ _IpcServer::SendResponse(int client, IPC::Message* pMessage) ret = g_io_channel_write_chars(pClientInfo->pReverseChannel, (char*) pData, remain, &written, &pGError); if (ret != G_IO_STATUS_NORMAL) { - SysLog(NID_IO, "Failed to send a response: %d", ret); - SysTryCatch(NID_IO, ret != G_IO_STATUS_ERROR, , E_SYSTEM, "[E_SYSTEM] Error occurred during writing message to socket."); + SysTryCatch(NID_IO, ret != G_IO_STATUS_AGAIN, , E_RESOURCE_UNAVAILABLE, "[E_RESOURCE_UNAVAILABLE] The socket buffer is full."); + + SysLogException(NID_IO, E_SYSTEM, "[E_SYSTEM] Failed to send a request: %d, %s", errno, strerror(errno)); + delete pMessage; + return E_SYSTEM; } remain -= written; @@ -773,8 +776,10 @@ _IpcServer::SendResponse(int client, const IPC::Message& message) ret = g_io_channel_write_chars(pClientInfo->pReverseChannel, (char*) pData, remain, &written, &pGError); if (ret != G_IO_STATUS_NORMAL) { - SysLog(NID_IO, "Failed to send a response: %d", ret); - SysTryCatch(NID_IO, ret != G_IO_STATUS_ERROR, , E_SYSTEM, "[E_SYSTEM] Error occurred during writing message to socket."); + SysTryCatch(NID_IO, ret != G_IO_STATUS_AGAIN, , E_RESOURCE_UNAVAILABLE, "[E_RESOURCE_UNAVAILABLE] The socket buffer is full."); + + SysLogException(NID_IO, E_SYSTEM, "[E_SYSTEM] Failed to send a request: %d, %s", errno, strerror(errno)); + return E_SYSTEM; } remain -= written; -- 2.7.4