OSDN Git Service

Changes to restart supplicant on crash
authorMahesh <mahe209069@gmail.com>
Wed, 14 May 2014 13:26:15 +0000 (18:56 +0530)
committerMahesh <mahe209069@gmail.com>
Thu, 15 May 2014 13:47:45 +0000 (19:17 +0530)
specify timeout value in poll to check if the supplicant
connection is active, if not we should indicate
terminate command to framework to restart supplicant.

Change-Id: I8e602b9cb07a13c3f0b96813b2fc89f46457473e

wifi/wifi.c

index 21f4577..5c16e3e 100644 (file)
@@ -687,6 +687,18 @@ int wifi_send_command(const char *cmd, char *reply, size_t *reply_len)
     return 0;
 }
 
+int wifi_supplicant_connection_active()
+{
+    char supp_status[PROPERTY_VALUE_MAX] = {'\0'};
+
+    if (property_get(supplicant_prop_name, supp_status, NULL)) {
+        if (strcmp(supp_status, "stopped") == 0)
+            return -1;
+    }
+
+    return 0;
+}
+
 int wifi_ctrl_recv(char *reply, size_t *reply_len)
 {
     int res;
@@ -698,11 +710,21 @@ int wifi_ctrl_recv(char *reply, size_t *reply_len)
     rfds[0].events |= POLLIN;
     rfds[1].fd = exit_sockets[1];
     rfds[1].events |= POLLIN;
-    res = TEMP_FAILURE_RETRY(poll(rfds, 2, -1));
-    if (res < 0) {
-        ALOGE("Error poll = %d", res);
-        return res;
-    }
+    do {
+        res = TEMP_FAILURE_RETRY(poll(rfds, 2, 30000));
+        if (res < 0) {
+            ALOGE("Error poll = %d", res);
+            return res;
+        } else if (res == 0) {
+            /* timed out, check if supplicant is active
+             * or not ..
+             */
+            res = wifi_supplicant_connection_active();
+            if (res < 0)
+                return -2;
+        }
+    } while (res == 0);
+
     if (rfds[0].revents & POLLIN) {
         return wpa_ctrl_recv(monitor_conn, reply, reply_len);
     }