sensord: skip the get_data process when there are some problems 15/64515/1
authorkibak.yoon <kibak.yoon@samsung.com>
Thu, 31 Mar 2016 01:43:55 +0000 (10:43 +0900)
committerkibak.yoon <kibak.yoon@samsung.com>
Fri, 1 Apr 2016 12:07:59 +0000 (21:07 +0900)
* after initializing data pointer, skip the get_data process

Change-Id: Ie4fc53f7d3f529821542875ff97f6839dce0dfee
Signed-off-by: kibak.yoon <kibak.yoon@samsung.com>
src/server/command_worker.cpp

index 83e5bce..3583223 100644 (file)
@@ -309,7 +309,8 @@ bool command_worker::send_cmd_get_data_done(int state, sensor_data_t *data)
        cmd_get_data_done = (cmd_get_data_done_t*)ret_packet->data();
        cmd_get_data_done->state = state;
 
-       memcpy(&cmd_get_data_done->base_data , data, sizeof(sensor_data_t));
+       if (data)
+               memcpy(&cmd_get_data_done->base_data, data, sizeof(sensor_data_t));
 
        if (m_socket.send(ret_packet->packet(), ret_packet->size()) <= 0) {
                _E("Failed to send a cmd_get_data_done");
@@ -707,13 +708,17 @@ bool command_worker::cmd_get_data(void *payload)
                _E("Permission denied to get data for client [%d], for sensor [0x%llx]",
                        m_client_id, m_sensor_id);
                state = OP_ERROR;
+               data = NULL;
                goto out;
        }
 
        remain_count = m_module->get_data(&data, &length);
 
-       if (remain_count < 0)
+       if (remain_count < 0) {
                state = OP_ERROR;
+               data = NULL;
+               goto out;
+       }
 
        // In case of not getting sensor data, wait short time and retry again
        // 1. changing interval to be less than 10ms