Skip to content

Commit

Permalink
PR feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
Bret Ambrose committed Mar 12, 2024
1 parent 590f947 commit bd04ad5
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
11 changes: 11 additions & 0 deletions source/request-response/request_response_client.c
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,9 @@ static struct aws_mqtt_request_response_client *s_aws_mqtt_request_response_clie
* initialize can't fail by checking its options for validity now.
*/
if (!aws_rr_subscription_manager_are_options_valid(&sm_options)) {
AWS_LOGF_ERROR(
AWS_LS_MQTT_REQUEST_RESPONSE, "(static) request response client creation failed - invalid client options");
aws_raise_error(AWS_ERROR_INVALID_ARGUMENT);
return NULL;
}

Expand Down Expand Up @@ -311,6 +314,10 @@ struct aws_mqtt_request_response_client *aws_mqtt_request_response_client_new_fr
struct aws_mqtt_request_response_client *rr_client =
s_aws_mqtt_request_response_client_new(allocator, options, aws_mqtt_client_connection_get_event_loop(client));

if (rr_client == NULL) {
return NULL;
}

struct aws_mqtt_protocol_adapter_options adapter_options = {
.subscription_event_callback = s_aws_rr_client_protocol_adapter_subscription_event_callback,
.incoming_publish_callback = s_aws_rr_client_protocol_adapter_incoming_publish_callback,
Expand Down Expand Up @@ -344,6 +351,10 @@ struct aws_mqtt_request_response_client *aws_mqtt_request_response_client_new_fr
struct aws_mqtt_request_response_client *rr_client =
s_aws_mqtt_request_response_client_new(allocator, options, client->loop);

if (rr_client == NULL) {
return NULL;
}

struct aws_mqtt_protocol_adapter_options adapter_options = {
.subscription_event_callback = s_aws_rr_client_protocol_adapter_subscription_event_callback,
.incoming_publish_callback = s_aws_rr_client_protocol_adapter_incoming_publish_callback,
Expand Down
13 changes: 7 additions & 6 deletions tests/request-response/request_response_client_tests.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ enum rr_test_client_protocol {
struct aws_rr_client_test_fixture {
struct aws_allocator *allocator;

struct aws_mqtt_request_response_client *client;
struct aws_mqtt_request_response_client *rr_client;

enum rr_test_client_protocol test_protocol;
union {
Expand Down Expand Up @@ -98,9 +98,9 @@ static int s_aws_rr_client_test_fixture_init_from_mqtt5(
client_options.terminated_callback = s_aws_rr_client_test_fixture_on_terminated;
client_options.user_data = fixture;

fixture->client = aws_mqtt_request_response_client_new_from_mqtt5_client(
fixture->rr_client = aws_mqtt_request_response_client_new_from_mqtt5_client(
allocator, fixture->client_test_fixture.mqtt5_test_fixture.client, &client_options);
AWS_FATAL_ASSERT(fixture->client != NULL);
AWS_FATAL_ASSERT(fixture->rr_client != NULL);

aws_mqtt5_client_start(fixture->client_test_fixture.mqtt5_test_fixture.client);

Expand Down Expand Up @@ -140,8 +140,9 @@ static int s_aws_rr_client_test_fixture_init_from_mqtt311(

struct aws_mqtt_client_connection *mqtt_client = fixture->client_test_fixture.mqtt311_test_fixture.mqtt_connection;

fixture->client = aws_mqtt_request_response_client_new_from_mqtt311_client(allocator, mqtt_client, &client_options);
AWS_FATAL_ASSERT(fixture->client != NULL);
fixture->rr_client =
aws_mqtt_request_response_client_new_from_mqtt311_client(allocator, mqtt_client, &client_options);
AWS_FATAL_ASSERT(fixture->rr_client != NULL);

struct aws_mqtt_connection_options connection_options = {
.user_data = &fixture->client_test_fixture.mqtt311_test_fixture,
Expand Down Expand Up @@ -169,7 +170,7 @@ static bool s_rr_client_test_fixture_terminated(void *context) {
}

static void s_aws_rr_client_test_fixture_clean_up(struct aws_rr_client_test_fixture *fixture) {
aws_mqtt_request_response_client_release(fixture->client);
aws_mqtt_request_response_client_release(fixture->rr_client);

aws_mutex_lock(&fixture->lock);
aws_condition_variable_wait_pred(&fixture->signal, &fixture->lock, s_rr_client_test_fixture_terminated, fixture);
Expand Down

0 comments on commit bd04ad5

Please sign in to comment.