Skip to content

Commit

Permalink
[C] Free idle strategy state if it is not explicitly assigned.
Browse files Browse the repository at this point in the history
  • Loading branch information
vyazelenko committed Nov 28, 2024
1 parent ad39d08 commit 5d24388
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
19 changes: 19 additions & 0 deletions aeron-archive/src/main/c/client/aeron_archive_context.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,19 @@ int aeron_archive_context_init(aeron_archive_context_t **ctx)
_ctx->control_term_buffer_sparse = AERON_ARCHIVE_CONTROL_TERM_BUFFER_SPARSE_DEFAULT;
_ctx->control_term_buffer_length = AERON_ARCHIVE_CONTROL_TERM_BUFFER_LENGTH_DEFAULT;

_ctx->idle_strategy_func = NULL;
_ctx->idle_strategy_state = NULL;
_ctx->owns_idle_strategy = false;

_ctx->error_handler = NULL;
_ctx->error_handler_clientd = NULL;

_ctx->delegating_invoker_func = NULL;
_ctx->delegating_invoker_func_clientd = NULL;

_ctx->on_recording_signal = NULL;
_ctx->on_recording_signal_clientd = NULL;

// like in Java the default value of the control MTU is defined by the driver configuration
_ctx->control_mtu_length = aeron_config_parse_size64(
"AERON_MTU_LENGTH",
Expand Down Expand Up @@ -185,6 +198,11 @@ int aeron_archive_context_close(aeron_archive_context_t *ctx)
aeron_free(ctx->control_response_channel);
aeron_free(ctx->recording_events_channel);

if (ctx->owns_idle_strategy)
{
aeron_free(ctx->idle_strategy_state);
}

aeron_free(ctx);
}

Expand Down Expand Up @@ -303,6 +321,7 @@ int aeron_archive_context_conclude(aeron_archive_context_t *ctx)

if (NULL == ctx->idle_strategy_func)
{
ctx->owns_idle_strategy = true;
if (NULL == (ctx->idle_strategy_func = aeron_idle_strategy_load(
"backoff",
&ctx->idle_strategy_state,
Expand Down
1 change: 1 addition & 0 deletions aeron-archive/src/main/c/client/aeron_archive_context.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ struct aeron_archive_context_stct

aeron_idle_strategy_func_t idle_strategy_func;
void *idle_strategy_state;
bool owns_idle_strategy;

aeron_archive_credentials_supplier_t credentials_supplier;

Expand Down

0 comments on commit 5d24388

Please sign in to comment.