diff options
author | Amarnath Hullur Subramanyam <amarnath@codeaurora.org> | 2015-08-26 20:27:59 -0700 |
---|---|---|
committer | Vineeta Srivastava <vsrivastava@google.com> | 2015-08-27 18:49:15 +0000 |
commit | f1c6382b7f8e3021f6ad308e4bd1fa8289b65516 (patch) | |
tree | f9e0326df0c27dbd95637cf3fa13075a2d1ca3ac | |
parent | 768f20bb55dc59e6955b2e2cbcaf2e3aecaf9742 (diff) | |
download | wlan-f1c6382b7f8e3021f6ad308e4bd1fa8289b65516.tar.gz |
WiFi-HAL: Unlock mutex before calling framework callback
As part of earlier commit log_handler and alert_handler were
protected by mutex. However, calling framework callback within
mutex context would cause deadlock, thus unlock mutex before
calling the framework callback and reacquire again when required.
Bug: 23530883
Change-Id: If4cd92be906307a9e5ff7a8002b219f93f1bda64
-rw-r--r-- | qcwcn/wifi_hal/rb_wrapper.cpp | 17 | ||||
-rw-r--r-- | qcwcn/wifi_hal/wifilogger.cpp | 10 |
2 files changed, 15 insertions, 12 deletions
diff --git a/qcwcn/wifi_hal/rb_wrapper.cpp b/qcwcn/wifi_hal/rb_wrapper.cpp index 4738628..932af06 100644 --- a/qcwcn/wifi_hal/rb_wrapper.cpp +++ b/qcwcn/wifi_hal/rb_wrapper.cpp @@ -104,13 +104,7 @@ void push_out_rb_data(void *cb_ctx) struct rb_info *rb_info = (struct rb_info *)cb_ctx; hal_info *info = (hal_info *)rb_info->ctx; wifi_ring_buffer_status rbs; - - pthread_mutex_lock(&info->lh_lock); - if (info->on_ring_buffer_data == NULL) { - ALOGE("on_ring_buffer_data handle is not set yet"); - pthread_mutex_unlock(&info->lh_lock); - return; - } + wifi_ring_buffer_data_handler handler; while (1) { size_t length = 0; @@ -121,10 +115,15 @@ void push_out_rb_data(void *cb_ctx) break; } get_rb_status(rb_info, &rbs); - info->on_ring_buffer_data(rb_info->name, (char *)buf, length, &rbs); + pthread_mutex_lock(&info->lh_lock); + handler.on_ring_buffer_data = info->on_ring_buffer_data; + pthread_mutex_unlock(&info->lh_lock); + if (handler.on_ring_buffer_data) { + handler.on_ring_buffer_data(rb_info->name, (char *)buf, + length, &rbs); + } free(buf); }; - pthread_mutex_unlock(&info->lh_lock); gettimeofday(&rb_info->last_push_time, NULL); } diff --git a/qcwcn/wifi_hal/wifilogger.cpp b/qcwcn/wifi_hal/wifilogger.cpp index 1baaed3..87b1412 100644 --- a/qcwcn/wifi_hal/wifilogger.cpp +++ b/qcwcn/wifi_hal/wifilogger.cpp @@ -199,11 +199,15 @@ void push_out_all_ring_buffers(hal_info *info) void send_alert(hal_info *info, int reason_code) { + wifi_alert_handler handler; + pthread_mutex_lock(&info->ah_lock); - if (info->on_alert) { - info->on_alert(0, NULL, 0, reason_code); - } + handler.on_alert = info->on_alert; pthread_mutex_unlock(&info->ah_lock); + + if (handler.on_alert) { + handler.on_alert(0, NULL, 0, reason_code); + } } void WifiLoggerCommand::setFeatureSet(u32 *support) { |