Add an error check in Ipc
authorSunwook Bae <sunwook45.bae@samsung.com>
Tue, 21 May 2013 08:49:51 +0000 (17:49 +0900)
committerSunwook Bae <sunwook45.bae@samsung.com>
Tue, 21 May 2013 08:49:51 +0000 (17:49 +0900)
Change-Id: Iff01302cbc26082ddc05ea76a3b1250337c09df7
Signed-off-by: Sunwook Bae <sunwook45.bae@samsung.com>
src/io/FIo_IpcClient.cpp
src/server/io/FIo_IpcServer.cpp

index 4b1e302..62a5957 100644 (file)
@@ -491,6 +491,14 @@ _IpcClient::SendAsync(IPC::Message* pMessage)
        while (remain > 0)
        {
                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);
+                       return E_SYSTEM;
+               }
+
                remain -= written;
                pData += written;
        }
index 62b8476..a55ce49 100644 (file)
@@ -705,6 +705,7 @@ _IpcServer::SendResponse(int client, IPC::Message* pMessage)
        char* pData = null;
        GError* pGError = null;
        _ClientInfo* pClientInfo = null;
+       int ret = 0;
 
        SysTryReturn(NID_IO, client >= 0 && pMessage != null, false, E_INVALID_ARG,
                                "[E_INVALID_ARG] pMessage(0x%x) is null or clinet(%d) < 0", pMessage,
@@ -722,7 +723,13 @@ _IpcServer::SendResponse(int client, IPC::Message* pMessage)
        while (remain > 0)
        {
                pGError = NULL;
-               g_io_channel_write_chars(pClientInfo->pReverseChannel, (char*) pData, remain, &written, &pGError);
+               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, pGError == null, , E_SYSTEM, "[E_SYSTEM] Error occurred during writing message to socket.");
 
                remain -= written;
@@ -749,6 +756,7 @@ _IpcServer::SendResponse(int client, const IPC::Message& message)
        char* pData = null;
        GError* pGError = null;
        _ClientInfo* pClientInfo = null;
+       int ret = 0;
 
        SysTryReturn(NID_IO, client >= 0, false, E_INVALID_ARG, "[E_INVALID_ARG] clinet(%d) < 0", client);
        SysTryCatch(NID_IO, !message.is_sync(), r = E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] Can't send sync. messagee.");
@@ -764,7 +772,13 @@ _IpcServer::SendResponse(int client, const IPC::Message& message)
        while (remain > 0)
        {
                pGError = NULL;
-               g_io_channel_write_chars(pClientInfo->pReverseChannel, (char*) pData, remain, &written, &pGError);
+               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, pGError == null, , E_SYSTEM, "[E_SYSTEM] Error occurred during writing message to socket.");
 
                remain -= written;