From 2631f993753d726c8c6a85ab66a83db79e54f0bb Mon Sep 17 00:00:00 2001 From: Irfan Sheriff Date: Wed, 27 Jan 2010 15:35:28 -0800 Subject: Return failures as strings to monitor Bug: 2399119 Change-Id: I17bcb86e002cd520f4275f3786cf54c82aaf59b7 --- wifi/wifi.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'wifi') diff --git a/wifi/wifi.c b/wifi/wifi.c index 8719cac..e6444f3 100644 --- a/wifi/wifi.c +++ b/wifi/wifi.c @@ -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); */ -- cgit v1.2.3