Prevent fix
authorSunwook Bae <sunwook45.bae@samsung.com>
Sat, 11 May 2013 02:24:29 +0000 (11:24 +0900)
committerSunwook Bae <sunwook45.bae@samsung.com>
Sat, 11 May 2013 02:24:29 +0000 (11:24 +0900)
Change-Id: Id8a1e13c8651ffa51025ad1bc6a2d47b7dc47d28
Signed-off-by: Sunwook Bae <sunwook45.bae@samsung.com>
src/io/FIo_IpcClient.cpp

index d403f64..1fd53cd 100644 (file)
@@ -539,12 +539,25 @@ _IpcClient::SendSync(IPC::Message* pMessage)
        pfd.events = POLLIN | POLLRDHUP;
        pfd.revents = 0;
 
+       int ret = 0;
+
        while (true)
        {
-               poll(&pfd, 1, -1);
+               ret = poll(&pfd, 1, -1);
+               if (ret < 0)
+               {
+                       if (errno == EINTR)
+                       {
+                               continue;
+                       }
+
+                       SysLogException(NID_IO, E_SYSTEM, "[E_SYSTEM] Failed to poll (%d, %s).", errno, strerror(errno));
+                       return E_SYSTEM;
+               }
 
                if (pfd.revents & POLLRDHUP)
                {
+                       SysLogException(NID_IO, E_SYSTEM, "[E_SYSTEM] POLLRDHUP");
                        return E_SYSTEM;
                }
 
@@ -553,7 +566,10 @@ _IpcClient::SendSync(IPC::Message* pMessage)
                        readSize = read(fd, buffer, 1024);
                }
 
-               message.append(buffer, readSize);
+               if (readSize > 0)
+               {
+                       message.append(buffer, readSize);
+               }
 
                pEndOfMessage = (char*) IPC::Message::FindNext(message.data(), message.data() + message.size());
                if (pEndOfMessage)