Skip to content

Commit d89dd07

Browse files
committed
Request response client: acquire event loop group
1 parent 9fc2f57 commit d89dd07

1 file changed

Lines changed: 13 additions & 1 deletion

File tree

source/request-response/request_response_client.c

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,7 @@ static void s_mqtt_request_response_client_final_destroy(struct aws_mqtt_request
319319
aws_mqtt_request_response_client_subscriptions_clean_up(&client->subscriptions);
320320
aws_hash_table_clean_up(&client->operations_by_correlation_tokens);
321321

322+
aws_event_loop_group_release_from_event_loop(client->loop);
322323
aws_mem_release(client->allocator, client);
323324

324325
if (terminate_callback != NULL) {
@@ -1060,9 +1061,20 @@ static struct aws_mqtt_request_response_client *s_aws_mqtt_request_response_clie
10601061

10611062
rr_client->allocator = allocator;
10621063
rr_client->config = *options;
1063-
rr_client->loop = loop;
10641064
rr_client->state = AWS_RRCS_UNINITIALIZED;
10651065

1066+
rr_client->loop = loop;
1067+
// kept a reference to the event loop group to keep the event loop alive. It should be released when the client is
1068+
// destroyed.
1069+
if (!aws_event_loop_group_acquire_from_event_loop(loop)) {
1070+
aws_mem_release(allocator, rr_client);
1071+
AWS_LOGF_ERROR(
1072+
AWS_LS_MQTT_REQUEST_RESPONSE,
1073+
"(static) request response client creation failed - unable to acquire event loop group");
1074+
aws_raise_error(AWS_ERROR_INVALID_ARGUMENT);
1075+
return NULL;
1076+
}
1077+
10661078
aws_hash_table_init(
10671079
&rr_client->operations,
10681080
allocator,

0 commit comments

Comments
 (0)