Skip to content

Commit cde64d6

Browse files
committed
acquire reference of event loop
1 parent f42cce5 commit cde64d6

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

source/request-response/request_response_client.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -410,6 +410,7 @@ static void s_mqtt_request_response_client_final_destroy(struct aws_mqtt_request
410410
aws_hash_table_clean_up(&client->request_response_paths);
411411
aws_hash_table_clean_up(&client->operations_by_correlation_tokens);
412412

413+
aws_event_loop_group_release_from_event_loop(client->loop);
413414
aws_mem_release(client->allocator, client);
414415

415416
if (terminate_callback != NULL) {
@@ -1152,6 +1153,18 @@ static struct aws_mqtt_request_response_client *s_aws_mqtt_request_response_clie
11521153

11531154
rr_client->allocator = allocator;
11541155
rr_client->config = *options;
1156+
1157+
// kept a reference to the event loop group to keep the event loop alive. It should be released when the client is
1158+
// destroyed.
1159+
if (!aws_event_loop_group_acquire_from_event_loop(loop)) {
1160+
aws_mem_release(allocator, rr_client);
1161+
AWS_LOGF_ERROR(
1162+
AWS_LS_MQTT_REQUEST_RESPONSE,
1163+
"(static) request response client creation failed - unable to acquire event loop group");
1164+
aws_raise_error(AWS_ERROR_INVALID_ARGUMENT);
1165+
return NULL;
1166+
}
1167+
11551168
rr_client->loop = loop;
11561169
rr_client->state = AWS_RRCS_UNINITIALIZED;
11571170

0 commit comments

Comments
 (0)