diff options
author | Amarnath Hullur Subramanyam <amarnath@codeaurora.org> | 2015-08-19 18:39:14 +0530 |
---|---|---|
committer | Vineeta Srivastava <vsrivastava@google.com> | 2015-08-19 16:52:15 -0700 |
commit | 32016d0baa7be9c4d1dd2f2fb68325f32ebf1267 (patch) | |
tree | 37f719764eb150c5cdbf54c943bded8c20c69858 | |
parent | 6c670f1cb4270f00e00b414a2c7cd20b878d8356 (diff) | |
download | android_hardware_qcom_wlan-32016d0baa7be9c4d1dd2f2fb68325f32ebf1267.tar.gz android_hardware_qcom_wlan-32016d0baa7be9c4d1dd2f2fb68325f32ebf1267.tar.bz2 android_hardware_qcom_wlan-32016d0baa7be9c4d1dd2f2fb68325f32ebf1267.zip |
WiFi-HAL: Protect log_handler and alert_handler with mutex
Protect log_handler and alert_handler with mutex as these
can be accessed in both command and event paths.
Bug: 23292340
Change-Id: I0565d818e97f81609152b288cc9074d995232744
-rw-r--r-- | qcwcn/wifi_hal/common.h | 4 | ||||
-rw-r--r-- | qcwcn/wifi_hal/rb_wrapper.cpp | 3 | ||||
-rw-r--r-- | qcwcn/wifi_hal/wifilogger.cpp | 19 |
3 files changed, 22 insertions, 4 deletions
diff --git a/qcwcn/wifi_hal/common.h b/qcwcn/wifi_hal/common.h index 7669422..a6d92be 100644 --- a/qcwcn/wifi_hal/common.h +++ b/qcwcn/wifi_hal/common.h @@ -129,6 +129,10 @@ typedef struct hal_info_s { u32 prev_seq_no; // pointer to structure having various gscan_event_handlers struct gscan_event_handlers_s *gscan_handlers; + /* mutex for the log_handler access*/ + pthread_mutex_t lh_lock; + /* mutex for the alert_handler access*/ + pthread_mutex_t ah_lock; } hal_info; wifi_error wifi_register_handler(wifi_handle handle, int cmd, nl_recvmsg_msg_cb_t func, void *arg); diff --git a/qcwcn/wifi_hal/rb_wrapper.cpp b/qcwcn/wifi_hal/rb_wrapper.cpp index 45b7ef5..4738628 100644 --- a/qcwcn/wifi_hal/rb_wrapper.cpp +++ b/qcwcn/wifi_hal/rb_wrapper.cpp @@ -105,8 +105,10 @@ void push_out_rb_data(void *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; } @@ -122,6 +124,7 @@ void push_out_rb_data(void *cb_ctx) info->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 9828eb7..1baaed3 100644 --- a/qcwcn/wifi_hal/wifilogger.cpp +++ b/qcwcn/wifi_hal/wifilogger.cpp @@ -199,10 +199,11 @@ void push_out_all_ring_buffers(hal_info *info) void send_alert(hal_info *info, int reason_code) { - //TODO check locking + pthread_mutex_lock(&info->ah_lock); if (info->on_alert) { info->on_alert(0, NULL, 0, reason_code); } + pthread_mutex_unlock(&info->ah_lock); } void WifiLoggerCommand::setFeatureSet(u32 *support) { @@ -545,7 +546,9 @@ wifi_error wifi_set_log_handler(wifi_request_id id, wifi_handle wifiHandle = getWifiHandle(iface); hal_info *info = getHalInfo(wifiHandle); + pthread_mutex_lock(&info->lh_lock); info->on_ring_buffer_data = handler.on_ring_buffer_data; + pthread_mutex_unlock(&info->lh_lock); if (handler.on_ring_buffer_data == NULL) { ALOGE("Set log handler is NULL"); return WIFI_ERROR_UNKNOWN; @@ -559,8 +562,9 @@ wifi_error wifi_reset_log_handler(wifi_request_id id, wifi_handle wifiHandle = getWifiHandle(iface); hal_info *info = getHalInfo(wifiHandle); - /* Some locking needs to be introduced here */ + pthread_mutex_lock(&info->lh_lock); info->on_ring_buffer_data = NULL; + pthread_mutex_unlock(&info->lh_lock); return WIFI_SUCCESS; } @@ -575,8 +579,9 @@ wifi_error wifi_set_alert_handler(wifi_request_id id, ALOGE("Set alert handler is NULL"); return WIFI_ERROR_UNKNOWN; } - //TODO check locking + pthread_mutex_lock(&info->ah_lock); info->on_alert = handler.on_alert; + pthread_mutex_unlock(&info->ah_lock); return WIFI_SUCCESS; } @@ -586,8 +591,9 @@ wifi_error wifi_reset_alert_handler(wifi_request_id id, wifi_handle wifiHandle = getWifiHandle(iface); hal_info *info = getHalInfo(wifiHandle); - /* Some locking needs to be introduced here */ + pthread_mutex_lock(&info->ah_lock); info->on_alert = NULL; + pthread_mutex_unlock(&info->ah_lock); return WIFI_SUCCESS; } @@ -698,6 +704,9 @@ wifi_error wifi_logger_ring_buffers_init(hal_info *info) goto cleanup; } + pthread_mutex_init(&info->lh_lock, NULL); + pthread_mutex_init(&info->ah_lock, NULL); + return ret; cleanup: @@ -712,6 +721,8 @@ void wifi_logger_ring_buffers_deinit(hal_info *info) for (i = 0; i < NUM_RING_BUFS; i++) { rb_deinit(&info->rb_infos[i]); } + pthread_mutex_destroy(&info->lh_lock); + pthread_mutex_destroy(&info->ah_lock); } |