Merge "Alarm Conditional AppLaunch Refactoring" into tizen_2.2
[platform/framework/native/appfw.git] / src / io / FIo_IpcClient.cpp
index 780bb7f..ef638b2 100644 (file)
@@ -57,7 +57,6 @@ namespace Tizen { namespace Io
 _IpcClient::_IpcClient(void)
        : __pReverseSource(null)
        , __fdCount(0)
-       , __timeout(-1)
        , __pFdLock(null)
        , __pListener(null)
 {
@@ -494,9 +493,20 @@ _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;
+                       }
+                       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;
                }
 
@@ -544,9 +554,20 @@ _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;
+                       }
+                       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;
                }
 
@@ -565,7 +586,7 @@ _IpcClient::SendSync(IPC::Message* pMessage)
 
        while (true)
        {
-               ret = poll(&pfd, 1, __timeout);
+               ret = poll(&pfd, 1, -1);
                if (ret < 0)
                {
                        if (errno == EINTR)
@@ -578,13 +599,6 @@ _IpcClient::SendSync(IPC::Message* pMessage)
                        ReleaseFd(fd);
                        return E_SYSTEM;
                }
-               else if (ret == 0)
-               {
-                       SysLogException(NID_IO, E_TIMEOUT, "[E_TIMEOUT] Timeout.");
-
-                       ReleaseFd(fd);
-                       return E_TIMEOUT;
-               }
 
                if (pfd.revents & POLLRDHUP)
                {
@@ -675,16 +689,4 @@ _IpcClient::SendRequest(const IPC::Message& message)
        return r;
 }
 
-void
-_IpcClient::SetTimeout(int timeout)
-{
-       __timeout = timeout;
-}
-
-int
-_IpcClient::GetTimeout(void) const
-{
-       return __timeout;
-}
-
 } } //Tizen::Io