@@ -1233,18 +1233,22 @@ static int s_add_request_operation_to_response_path_table(
12331233 return AWS_OP_SUCCESS ;
12341234}
12351235
1236- static int s_add_request_operation_to_correlation_token_table (
1236+ static bool s_is_correlation_token_in_use (
12371237 struct aws_mqtt_request_response_client * client ,
12381238 struct aws_mqtt_rr_client_operation * operation ) {
1239-
1240- // First inspect whether the correlation token is already in use
12411239 struct aws_hash_element * elem = NULL ;
12421240 aws_hash_table_find (
12431241 & client -> operations_by_correlation_tokens ,
12441242 & operation -> storage .request_storage .options .correlation_token ,
12451243 & elem );
1246- if (elem != NULL ) {
1247- // correlation token is already in use. Return appropriate error.
1244+ return elem == NULL ;
1245+ }
1246+
1247+ static int s_add_request_operation_to_correlation_token_table (
1248+ struct aws_mqtt_request_response_client * client ,
1249+ struct aws_mqtt_rr_client_operation * operation ) {
1250+
1251+ if (s_is_correlation_token_in_use (client , operation )) {
12481252 aws_raise_error (AWS_ERROR_MQTT_REQUEST_RESPONSE_DUPLICATE_CORRELATION_TOKEN );
12491253 return AWS_OP_ERR ;
12501254 }
@@ -1291,7 +1295,7 @@ static void s_handle_operation_subscribe_result(
12911295 }
12921296
12931297 if (s_add_in_progress_operation_to_tracking_tables (client , operation )) {
1294- s_request_response_fail_operation (operation , AWS_ERROR_MQTT_REQUEST_RESPONSE_INTERNAL_ERROR );
1298+ s_request_response_fail_operation (operation , aws_last_error () );
12951299 return ;
12961300 }
12971301
0 commit comments