summaryrefslogtreecommitdiffstats
path: root/wifi
diff options
context:
space:
mode:
authorIrfan Sheriff <isheriff@google.com>2011-08-22 13:27:56 -0700
committerrepo sync <isheriff@google.com>2011-08-22 13:35:48 -0700
commit5a8a2d2b130644f0f4abad8586f0a245e4c15be8 (patch)
tree6e4bd80b14f80ddfc89e056e2eee8685e4118e2d /wifi
parent841667015b0781419ee944801f45ba2d10f7203d (diff)
downloadhardware_libhardware_legacy-5a8a2d2b130644f0f4abad8586f0a245e4c15be8.zip
hardware_libhardware_legacy-5a8a2d2b130644f0f4abad8586f0a245e4c15be8.tar.gz
hardware_libhardware_legacy-5a8a2d2b130644f0f4abad8586f0a245e4c15be8.tar.bz2
Fix system property race at supplicant stop
We stop supplicant by sending a "terminate" control command. init then updates the system property init.svc.wpa_supplicant when the supplicant has stopped. The framework gets notified of a successful supplicant stop through a supplicant event. It can happen that the framework has been notified of a supplicant stop, but the init process has not set the system property and thus when the framework tries to connect to the supplicant again, it can immediately return saying the supplicant is already running. Avoid this race, by ensuring the call from framework to close supplicant connection polls for the update by init process that the system property indicates supplicant has stopped. Bug: 5166494 Change-Id: Ie74a8cf39fa56ae557ea6bbbcba7865301620c42
Diffstat (limited to 'wifi')
-rw-r--r--wifi/wifi.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/wifi/wifi.c b/wifi/wifi.c
index be0aaeb..d455a0b 100644
--- a/wifi/wifi.c
+++ b/wifi/wifi.c
@@ -659,6 +659,9 @@ int wifi_wait_for_event(char *buf, size_t buflen)
void wifi_close_supplicant_connection()
{
+ char supp_status[PROPERTY_VALUE_MAX] = {'\0'};
+ int count = 50; /* wait at most 5 seconds to ensure init has stopped stupplicant */
+
if (ctrl_conn != NULL) {
wpa_ctrl_close(ctrl_conn);
ctrl_conn = NULL;
@@ -667,6 +670,14 @@ void wifi_close_supplicant_connection()
wpa_ctrl_close(monitor_conn);
monitor_conn = NULL;
}
+
+ while (count-- > 0) {
+ if (property_get(SUPP_PROP_NAME, supp_status, NULL)) {
+ if (strcmp(supp_status, "stopped") == 0)
+ return;
+ }
+ usleep(100000);
+ }
}
int wifi_command(const char *command, char *reply, size_t *reply_len)