summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYuanyuan Liu <yuanliu@codeaurora.org>2017-05-10 12:05:11 -0700
committercodeworkx <daniel.hillenbrand@codeworkx.de>2018-02-18 12:04:06 +0100
commite44b04944eb9da6ad0b6655e0d7b8a8d72bbd26d (patch)
tree2d3e1f019225b48f49597cc84a73a7170edbc661
parent222f69c7d1098c5b52a9df9448516c2c61cfec61 (diff)
downloadandroid_frameworks_opt_net_wifi-e44b04944eb9da6ad0b6655e0d7b8a8d72bbd26d.tar.gz
android_frameworks_opt_net_wifi-e44b04944eb9da6ad0b6655e0d7b8a8d72bbd26d.tar.bz2
android_frameworks_opt_net_wifi-e44b04944eb9da6ad0b6655e0d7b8a8d72bbd26d.zip
wifi: Check whether dev node is accessible or not before opening
wifi framework tries to open dev node WIFI_DRIVER_STATE_CTRL_PARAM as part of initialization/turn on. But this dev node may not be present/not accessible by then. So check for the existence/accessibility of dev node by retrying few times to avoid possible race condition between creation and accessing of this node. Test: manual test Bug: 72196764 Change-Id: Iff283bf4f8dcf305785891d142e50afd6dc65875
-rw-r--r--libwifi_hal/wifi_hal_common.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/libwifi_hal/wifi_hal_common.cpp b/libwifi_hal/wifi_hal_common.cpp
index 14a0b6247..599434f82 100644
--- a/libwifi_hal/wifi_hal_common.cpp
+++ b/libwifi_hal/wifi_hal_common.cpp
@@ -93,8 +93,20 @@ int wifi_change_driver_state(const char *state) {
int len;
int fd;
int ret = 0;
+ int count = 5; /* wait at most 1 second for completion */
if (!state) return -1;
+
+ do {
+ if (access(WIFI_DRIVER_STATE_CTRL_PARAM, R_OK|W_OK) == 0)
+ break;
+ usleep(200000);
+ } while (--count > 0);
+ if (count == 0) {
+ PLOG(ERROR) << "Failed to access driver state control param " << strerror(errno) << ", " << errno;
+ return -1;
+ }
+
fd = TEMP_FAILURE_RETRY(open(WIFI_DRIVER_STATE_CTRL_PARAM, O_WRONLY));
if (fd < 0) {
PLOG(ERROR) << "Failed to open driver state control param";