Check POLLIN revent before POLLHUP. 45/118445/1
authorjin-gyu.kim <jin-gyu.kim@samsung.com>
Fri, 10 Mar 2017 10:28:59 +0000 (19:28 +0900)
committerjin-gyu.kim <jin-gyu.kim@samsung.com>
Fri, 10 Mar 2017 10:29:03 +0000 (19:29 +0900)
- Askuser does not work well with the emulator.
- This is due to that POLLHUP can be came in case of EOF.

Change-Id: If668886b050e07a8606e45fdd6d54cbb70ed2208

src/agent/ui/NotificationBackend.cpp

index 68092c5..2519ff7 100644 (file)
@@ -173,6 +173,20 @@ bool NotificationBackend::mainLoop() {
             return false;
         }
 
+        if (m_poller.getEvents(m_clientSocket.getFd()) & POLLIN) {
+            NotificationResponse response;
+            if (!recvResponse(response)) {
+                ALOGE("Couldn't receive response");
+                return false;
+            }
+            if (!parseResponse(response)) {
+                ALOGE("Incorrect response received");
+                return false;
+            }
+            m_responseHandler(m_request.id, NResponseTypeToUI(response.response));
+            return true;
+        }
+
         if (m_poller.getEvents(m_clientSocket.getFd()) & POLLHUP) {
             ALOGE("Service disconnected");
             return false;
@@ -187,20 +201,6 @@ bool NotificationBackend::mainLoop() {
             m_poller.setEvents(m_clientSocket.getFd(), POLLIN | POLLERR);
             continue;
         }
-
-        if (m_poller.getEvents(m_clientSocket.getFd()) & POLLIN) {
-            NotificationResponse response;
-            if (!recvResponse(response)) {
-                ALOGE("Couldn't receive response");
-                return false;
-            }
-            if (!parseResponse(response)) {
-                ALOGE("Incorrect response received");
-                return false;
-            }
-            m_responseHandler(m_request.id, NResponseTypeToUI(response.response));
-            return true;
-        }
     }
 
     ALOGD("NotificationBackend loop ended");