Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions source/platform/common/data_model/wifi_dml_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -1989,6 +1989,7 @@ static int update_json_param_legacy(char *p_key, char *partner_id, char *p_value
if (data != NULL) {
memset(data, 0, (sizeof(char) * (len + 1)));
if (1 != fread(data, len, 1, file_read)) {
free(data);
fclose(file_read);
return RETURN_ERR;
}
Expand All @@ -2005,10 +2006,10 @@ static int update_json_param_legacy(char *p_key, char *partner_id, char *p_value
return RETURN_ERR;
} else if (strlen(data) != 0) {
json = cJSON_Parse(data);
free(data);
if (!json) {
wifi_util_error_print(WIFI_DMCLI, "%s : json file parser error : [%d]\n", __func__,
__LINE__);
free(data);
return RETURN_ERR;
} else {
partner_obj = cJSON_GetObjectItem(json, partner_id);
Expand Down Expand Up @@ -2084,6 +2085,7 @@ int update_json_param(char *p_key, char *partner_id, char *p_value, char *p_sour
if (data != NULL) {
memset(data, 0, (sizeof(char) * (len + 1)));
if (1 != fread(data, len, 1, file_read)) {
free(data);
fclose(file_read);
return RETURN_ERR;
}
Expand All @@ -2101,10 +2103,10 @@ int update_json_param(char *p_key, char *partner_id, char *p_value, char *p_sour
return RETURN_ERR;
} else if (strlen(data) != 0) {
json = cJSON_Parse(data);
free(data);
if (!json) {
wifi_util_error_print(WIFI_DMCLI, "%s : json file parser error : [%d]\n", __func__,
__LINE__);
free(data);
return RETURN_ERR;
} else {
partner_obj = cJSON_GetObjectItem(json, partner_id);
Expand Down
7 changes: 6 additions & 1 deletion source/platform/linux/he_bus/src/he_bus_connection.c
Original file line number Diff line number Diff line change
Expand Up @@ -627,6 +627,9 @@ void *ipc_unix_broadcast_client_start(void *arg)
if (FD_ISSET(p_client_info->conn_info.fd, &read_fds)) {
ret = recv_server_data(handle, &p_client_info->conn_info);
if (ret == HE_BUS_ERROR_STREAM_CLOSED) {
if (p_client_info->conn_info.fd != SOCKET_INVALID_FD) {
close(p_client_info->conn_info.fd);
}
p_client_info->conn_info.fd = -1;
sleep(20); //@TODO TBD Do we need to trigger retry for server connection ?
if (bus_client_bind(SOCKET_BROADCAST_SERVER_NAME, &p_client_info->conn_info) !=
Expand All @@ -640,7 +643,9 @@ void *ipc_unix_broadcast_client_start(void *arg)
}
}
}
close(p_client_info->conn_info.fd);
if (p_client_info->conn_info.fd != SOCKET_INVALID_FD) {
close(p_client_info->conn_info.fd);
}
return NULL;
}

Expand Down
22 changes: 12 additions & 10 deletions source/platform/linux/he_bus/src/he_bus_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,7 @@ element_node_t *bus_insert_element(he_bus_handle_t handle, element_node_t *root,
Its presumed a provider will register more elements under this, such as
Device.WiFi.AccessPoint.{i}.Foo etc,...
*/
if (elem->type == he_bus_element_type_table) {
if (elem->type == he_bus_element_type_table && current_node->child == NULL) {
// trigger add table registration callback
element_node_t *rowTemplate = get_empty_element_node();
rowTemplate->parent = current_node;
Expand Down Expand Up @@ -903,7 +903,8 @@ he_bus_error_t he_bus_event_sub_to_provider(he_bus_handle_t handle,

char *event_name;
he_bus_raw_data_msg_t sub_data = { 0 };
he_bus_raw_data_t payload_data;
he_bus_raw_data_t payload_data = { 0 };
he_bus_stretch_buff_t raw_buff = { 0 };
int ret;
sub_payload_data_t sub_input_data;

Expand All @@ -921,8 +922,8 @@ he_bus_error_t he_bus_event_sub_to_provider(he_bus_handle_t handle,
if (p_sub_data != NULL) {
he_bus_core_error_print("%s:%d event:%s already subscribe with provider\r\n", __func__,
__LINE__, event_name);
return he_bus_error_subscription_already_exist; // @TODO TBD Do we need to return error
// or not ?
status = he_bus_error_subscription_already_exist;
goto cleanup; // @TODO TBD Do we need to return error or not ?
} else {
sub_input_data.action = sub_data_map[index].action;
sub_input_data.interval = sub_data_map[index].interval;
Expand All @@ -937,18 +938,17 @@ he_bus_error_t he_bus_event_sub_to_provider(he_bus_handle_t handle,
if (status != he_bus_error_success) {
he_bus_core_error_print("%s:%d rem bus payload preapre is failed:%d for %s\r\n",
__func__, __LINE__, status, event_name);
return status;
he_bus_free(payload_data.raw_data.bytes);
goto cleanup;
}
}
}

he_bus_stretch_buff_t raw_buff = { 0 };

if (convert_bus_raw_msg_data_to_buffer(&sub_data, &raw_buff) != he_bus_error_success) {
he_bus_core_error_print("%s:%d wrong data for :%s namespace\r\n", __func__, __LINE__,
sub_data.component_name);
FREE_BUFF_MEMORY(raw_buff.buff);
return he_bus_error_invalid_input;
status = he_bus_error_invalid_input;
goto cleanup;
}

he_bus_core_info_print("%s:%d event:%s subscribe event sub type:%d\r\n", __func__, __LINE__,
Expand Down Expand Up @@ -992,14 +992,16 @@ he_bus_error_t he_bus_event_sub_to_provider(he_bus_handle_t handle,
if (ret != HE_BUS_RETURN_OK) {
he_bus_core_info_print("%s:%d event:%s subscribe send failure:%d\r\n", __func__,
__LINE__, event_name, ret);
return he_bus_error_destination_not_reachable;
status = he_bus_error_destination_not_reachable;
goto cleanup;
} else {
for (uint32_t index = 0; index < num_of_sub; index++) {
save_bus_sub_event_entries(handle, handle->sub_map, &sub_data_map[index]);
}
}
}

cleanup:
FREE_BUFF_MEMORY(raw_buff.buff);
free_bus_msg_obj_data(&sub_data.data_obj);
return status;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -600,6 +600,7 @@ he_bus_error_t process_bus_sub_event(he_bus_handle_t handle, int socket_fd, char
p_obj_data->data.raw_data_len);
p_sub_data->action = sub_recv_data.action;
} else {
he_bus_free(p_sub_data);
ELM_UNLOCK(node->element_mutex);
he_bus_core_error_print("%s:%d wrong sub action raw data type:%d for %s\r\n",
__func__, __LINE__, p_obj_data->data.data_type, p_obj_data->name);
Expand Down
4 changes: 4 additions & 0 deletions source/platform/rdkb/bus.c
Original file line number Diff line number Diff line change
Expand Up @@ -1388,6 +1388,7 @@ static bus_error_t bus_data_get(bus_handle_t *handle, char const *name, raw_data
if (data->raw_data.bytes == NULL) {
wifi_util_error_print(WIFI_BUS, "%s:%d: bus: memory alloc is failed:%d for name:%s\n",
__func__, __LINE__, len, name);
rbusValue_Release(value);
return bus_error_out_of_resources;
}
memcpy(data->raw_data.bytes, ptr, len);
Expand Down Expand Up @@ -1677,11 +1678,13 @@ bus_error_t bus_method_invoke(bus_handle_t *handle, void *paramName, char *event
prop = rbusObject_GetProperties(outParams);
if (prop == NULL) {
wifi_util_error_print(WIFI_BUS, "%s %d prop is NULL\n", __func__, __LINE__);
rbusObject_Release(outParams);
return bus_error_general;
}
value = rbusProperty_GetValue(prop);
if (value == NULL) {
wifi_util_error_print(WIFI_BUS, "%s %d value is NULL\n", __func__, __LINE__);
rbusObject_Release(outParams);
return bus_error_general;
}
switch (output_data->data_type) {
Expand Down Expand Up @@ -1722,6 +1725,7 @@ bus_error_t bus_method_invoke(bus_handle_t *handle, void *paramName, char *event
if (output_data->raw_data.bytes == NULL) {
wifi_util_error_print(WIFI_BUS, "%s:%d: bus: memory alloc is failed:%d for name:%s\n",
__func__, __LINE__, len, event);
rbusObject_Release(outParams);
return bus_error_out_of_resources;
}
memcpy(output_data->raw_data.bytes, ptr, len);
Expand Down
Loading