@@ -2793,7 +2793,7 @@ static void s_aws_mqtt_set_metrics_task_destroy(struct aws_mqtt_set_metrics_task
27932793 return ;
27942794 }
27952795
2796- aws_mqtt_iot_sdk_metrics_storage_clean_up (task -> metrics_storage );
2796+ aws_mqtt_iot_sdk_metrics_storage_destroy (task -> metrics_storage );
27972797
27982798 aws_mem_release (task -> allocator , task );
27992799}
@@ -2807,43 +2807,22 @@ static void s_set_metrics_task_fn(struct aws_task *task, void *arg, enum aws_tas
28072807 goto done ;
28082808 }
28092809
2810- /* we're in the mqtt5 client's event loop; it's safe to access internal state */
2811- struct aws_mqtt5_packet_connect_storage * old_connect = adapter -> client -> config -> connect ;
2812-
2813- /*
2814- * Packet storage stores binary data in a single buffer. The safest way to replace some binary data is
2815- * to make a new storage from the old storage, deleting the old storage after construction is complete.
2816- */
2817- struct aws_mqtt5_packet_connect_view new_connect_view = old_connect -> storage_view ;
2818-
2819- if (set_task -> metrics_storage ) {
2820- new_connect_view .metrics = & set_task -> metrics_storage -> storage_view ;
2821- } else {
2822- new_connect_view .metrics = NULL ;
2823- }
2824-
2825- if (aws_mqtt5_packet_connect_view_validate (& new_connect_view )) {
2826- AWS_LOGF_ERROR (
2827- AWS_LS_MQTT5_TO_MQTT3_ADAPTER , "id=%p: mqtt3-to-5-adapter - invalid CONNECT metrics" , (void * )adapter );
2810+ if (aws_mqtt_validate_iot_sdk_metrics_utf8 (& set_task -> metrics_storage -> storage_view )) {
2811+ AWS_LOGF_ERROR (AWS_LS_MQTT5_TO_MQTT3_ADAPTER , "invalid metrics in client configuration" );
28282812 goto done ;
28292813 }
28302814
2831- struct aws_mqtt5_packet_connect_storage * new_connect =
2832- aws_mem_calloc (adapter -> allocator , 1 , sizeof (struct aws_mqtt5_packet_connect_storage ));
2833-
2834- if (aws_mqtt5_packet_connect_storage_init (new_connect , adapter -> allocator , & new_connect_view )) {
2835- aws_mem_release (adapter -> allocator , new_connect );
2836- goto done ;
2815+ /* we're in the mqtt5 client's event loop; it's safe to access internal state */
2816+ struct aws_mqtt5_client_options_storage * client_options = adapter -> client -> config ;
2817+ if (client_options -> metrics_storage ) {
2818+ aws_mqtt_iot_sdk_metrics_storage_destroy (client_options -> metrics_storage );
28372819 }
2838-
2839- adapter -> client -> config -> connect = new_connect ;
2840- aws_mqtt5_packet_connect_storage_clean_up (old_connect );
2841- aws_mem_release (old_connect -> allocator , old_connect );
2820+ client_options -> metrics_storage =
2821+ aws_mqtt_iot_sdk_metrics_storage_new (set_task -> allocator , & set_task -> metrics_storage -> storage_view );
2822+ client_options -> options .metrics = & client_options -> metrics_storage -> storage_view ;
28422823
28432824done :
2844-
28452825 aws_ref_count_release (& adapter -> internal_refs );
2846-
28472826 s_aws_mqtt_set_metrics_task_destroy (set_task );
28482827}
28492828
@@ -2862,12 +2841,7 @@ static struct aws_mqtt_set_metrics_task *s_aws_mqtt_set_metrics_task_new(
28622841 set_task -> adapter = (struct aws_mqtt_client_connection_5_impl * )aws_ref_count_acquire (& adapter -> internal_refs );
28632842
28642843 if (metrics != NULL ) {
2865- set_task -> metrics_storage = aws_mem_calloc (allocator , 1 , sizeof (struct aws_mqtt_iot_sdk_metrics_storage ));
2866- if (aws_mqtt_iot_sdk_metrics_storage_init (set_task -> metrics_storage , allocator , metrics )) {
2867- aws_ref_count_release (& adapter -> internal_refs );
2868- aws_mem_release (allocator , set_task );
2869- return NULL ;
2870- }
2844+ set_task -> metrics_storage = aws_mqtt_iot_sdk_metrics_storage_new (allocator , metrics );
28712845 }
28722846
28732847 return set_task ;
@@ -2925,7 +2899,8 @@ static uint16_t s_aws_mqtt_5_resubscribe_existing_topics(
29252899 int error_code = aws_last_error ();
29262900 AWS_LOGF_ERROR (
29272901 AWS_LS_MQTT5_TO_MQTT3_ADAPTER ,
2928- "id=%p: mqtt3-to-5-adapter, resubscribe_existing_topics failed on operation creation, error code %d(%s)" ,
2902+ "id=%p: mqtt3-to-5-adapter, resubscribe_existing_topics failed on operation creation, error code "
2903+ "%d(%s)" ,
29292904 (void * )adapter ,
29302905 error_code ,
29312906 aws_error_debug_str (error_code ));
0 commit comments