OSDN Git Service

Return failures as strings to monitor
authorIrfan Sheriff <isheriff@google.com>
Wed, 27 Jan 2010 23:35:28 +0000 (15:35 -0800)
committerIrfan Sheriff <isheriff@google.com>
Thu, 28 Jan 2010 17:39:50 +0000 (09:39 -0800)
Bug: 2399119
Change-Id: I17bcb86e002cd520f4275f3786cf54c82aaf59b7

wifi/wifi.c

index 8719cac..e6444f3 100644 (file)
@@ -427,13 +427,18 @@ int wifi_wait_for_event(char *buf, size_t buflen)
     struct timeval tval;
     struct timeval *tptr;
     
-    if (monitor_conn == NULL)
-        return 0;
+    if (monitor_conn == NULL) {
+        strncpy(buf, WPA_EVENT_TERMINATING " - connection closed", buflen-1);
+        buf[buflen-1] = '\0';
+        return strlen(buf);
+    }
 
     result = wpa_ctrl_recv(monitor_conn, buf, &nread);
     if (result < 0) {
         LOGD("wpa_ctrl_recv failed: %s\n", strerror(errno));
-        return -1;
+        strncpy(buf, WPA_EVENT_TERMINATING " - recv error", buflen-1);
+        buf[buflen-1] = '\0';
+        return strlen(buf);
     }
     buf[nread] = '\0';
     /* LOGD("wait_for_event: result=%d nread=%d string=\"%s\"\n", result, nread, buf); */