Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion source/s3.c
Original file line number Diff line number Diff line change
Expand Up @@ -121,13 +121,17 @@ AWS_STATIC_STRING_FROM_LITERAL(s_CopyObject_str, "CopyObject");
AWS_STATIC_STRING_FROM_LITERAL(s_PutObject_str, "PutObject");
AWS_STATIC_STRING_FROM_LITERAL(s_CreateSession_str, "CreateSession");

static bool s_byte_cursor_eq_ignore_case(const void *a, const void *b) {
return aws_byte_cursor_eq_ignore_case(a, b);
}

static void s_s3_request_type_info_init(struct aws_allocator *allocator) {
int err = aws_hash_table_init(
&s_s3_operation_name_to_request_type_table,
allocator,
AWS_ARRAY_SIZE(s_s3_request_type_info_array) /*initial_size*/,
aws_hash_byte_cursor_ptr_ignore_case,
(aws_hash_callback_eq_fn *)aws_byte_cursor_eq_ignore_case,
s_byte_cursor_eq_ignore_case,
NULL /*destroy_key*/,
NULL /*destroy_value*/);
AWS_FATAL_ASSERT(!err);
Expand Down
6 changes: 5 additions & 1 deletion source/s3_checksum_stream.c
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,10 @@ static void s_aws_input_checksum_stream_destroy(struct aws_checksum_stream *impl
aws_mem_release(impl->allocator, impl);
}

static void s_aws_input_checksum_stream_destroy_wrap(void *user_data) {
s_aws_input_checksum_stream_destroy(user_data);
}

static struct aws_input_stream_vtable s_aws_input_checksum_stream_vtable = {
.seek = s_aws_input_checksum_stream_seek,
.read = s_aws_input_checksum_stream_read,
Expand All @@ -129,7 +133,7 @@ static struct aws_checksum_stream *s_aws_checksum_input_checksum_stream_new(
aws_byte_buf_init(&impl->checksum_result, allocator, impl->checksum->digest_size);
impl->old_stream = aws_input_stream_acquire(existing_stream);
aws_ref_count_init(
&impl->base.ref_count, impl, (aws_simple_completion_callback *)s_aws_input_checksum_stream_destroy);
&impl->base.ref_count, impl, s_aws_input_checksum_stream_destroy_wrap);
return impl;
on_error:
aws_mem_release(impl->allocator, impl);
Expand Down
6 changes: 5 additions & 1 deletion source/s3_chunk_stream.c
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,10 @@ static void s_aws_input_chunk_stream_destroy(struct aws_chunk_stream *impl) {
}
}

static void s_aws_input_chunk_stream_destroy_wrap(void *user_data) {
s_aws_input_chunk_stream_destroy(user_data);
}

static struct aws_input_stream_vtable s_aws_input_chunk_stream_vtable = {
.seek = s_aws_input_chunk_stream_seek,
.read = s_aws_input_chunk_stream_read,
Expand Down Expand Up @@ -257,7 +261,7 @@ struct aws_input_stream *aws_chunk_stream_new(
checksum_context->encoded_checksum_size + post_trailer_len;

AWS_ASSERT(impl->current_stream);
aws_ref_count_init(&impl->base.ref_count, impl, (aws_simple_completion_callback *)s_aws_input_chunk_stream_destroy);
aws_ref_count_init(&impl->base.ref_count, impl, s_aws_input_chunk_stream_destroy_wrap);
return &impl->base;

error:
Expand Down
6 changes: 5 additions & 1 deletion source/s3_default_buffer_pool.c
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,10 @@ static void s_destroy_special_block_list(void *val) {
aws_mem_release(special_list->allocator, special_list);
}

static void s_aws_s3_default_buffer_pool_destroy_wrap(void *user_data) {
aws_s3_default_buffer_pool_destroy(user_data);
}

struct aws_s3_buffer_pool *aws_s3_default_buffer_pool_new(
struct aws_allocator *allocator,
struct aws_s3_buffer_pool_config config) {
Expand Down Expand Up @@ -295,7 +299,7 @@ struct aws_s3_buffer_pool *aws_s3_default_buffer_pool_new(
struct aws_s3_buffer_pool *pool = aws_mem_calloc(buffer_pool->base_allocator, 1, sizeof(struct aws_s3_buffer_pool));
pool->impl = buffer_pool;
pool->vtable = &s_default_pool_vtable;
aws_ref_count_init(&pool->ref_count, pool, (aws_simple_completion_callback *)aws_s3_default_buffer_pool_destroy);
aws_ref_count_init(&pool->ref_count, pool, s_aws_s3_default_buffer_pool_destroy_wrap);

return pool;
}
Expand Down
7 changes: 6 additions & 1 deletion source/s3_parallel_input_stream.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@

AWS_STATIC_STRING_FROM_LITERAL(s_readonly_bytes_mode, "rb");

static void s_parallel_stream_vtable_destroy_wrap(void *user_data) {
struct aws_parallel_input_stream *stream = user_data;
stream->vtable->destroy(stream);
}

void aws_parallel_input_stream_init_base(
struct aws_parallel_input_stream *stream,
struct aws_allocator *alloc,
Expand All @@ -28,7 +33,7 @@ void aws_parallel_input_stream_init_base(
stream->vtable = vtable;
stream->impl = impl;
stream->shutdown_future = aws_future_void_new(alloc);
aws_ref_count_init(&stream->ref_count, stream, (aws_simple_completion_callback *)vtable->destroy);
aws_ref_count_init(&stream->ref_count, stream, s_parallel_stream_vtable_destroy_wrap);
}

struct aws_parallel_input_stream *aws_parallel_input_stream_acquire(struct aws_parallel_input_stream *stream) {
Expand Down
6 changes: 5 additions & 1 deletion source/s3_platform_info.c
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,10 @@ static void s_destroy_loader(void *arg) {
aws_mem_release(loader->allocator, loader);
}

static bool s_byte_cursor_eq_ignore_case(const void *a, const void *b) {
return aws_byte_cursor_eq_ignore_case(a, b);
}

struct aws_s3_platform_info_loader *aws_s3_platform_info_loader_new(struct aws_allocator *allocator) {
struct aws_s3_platform_info_loader *loader =
aws_mem_calloc(allocator, 1, sizeof(struct aws_s3_platform_info_loader));
Expand All @@ -175,7 +179,7 @@ struct aws_s3_platform_info_loader *aws_s3_platform_info_loader_new(struct aws_a
allocator,
32,
aws_hash_byte_cursor_ptr_ignore_case,
(aws_hash_callback_eq_fn *)aws_byte_cursor_eq_ignore_case,
s_byte_cursor_eq_ignore_case,
NULL,
NULL) &&
"Hash table init failed!");
Expand Down
25 changes: 21 additions & 4 deletions source/s3express_credentials_provider.c
Original file line number Diff line number Diff line change
Expand Up @@ -914,6 +914,11 @@ static void s_bg_refresh_task(struct aws_task *task, void *arg, enum aws_task_st
}
}

static void s_provider_vtable_destroy_wrap(void *user_data) {
struct aws_s3express_credentials_provider *provider = user_data;
provider->vtable->destroy(provider);
}

void aws_s3express_credentials_provider_init_base(
struct aws_s3express_credentials_provider *provider,
struct aws_allocator *allocator,
Expand All @@ -926,7 +931,19 @@ void aws_s3express_credentials_provider_init_base(
provider->allocator = allocator;
provider->vtable = vtable;
provider->impl = impl;
aws_ref_count_init(&provider->ref_count, provider, (aws_simple_completion_callback *)provider->vtable->destroy);
aws_ref_count_init(&provider->ref_count, provider, s_provider_vtable_destroy_wrap);
}

static bool s_string_eq(const void *a, const void *b) {
return aws_string_eq(a, b);
}

static void s_s3express_session_destroy(void *value) {
s_aws_s3express_session_destroy(value);
}

static void s_finish_provider_destroy_wrap(void *user_data) {
s_finish_provider_destroy(user_data);
}

struct aws_s3express_credentials_provider *aws_s3express_credentials_provider_new_default(
Expand Down Expand Up @@ -969,9 +986,9 @@ struct aws_s3express_credentials_provider *aws_s3express_credentials_provider_ne
impl->synced_data.cache = aws_cache_new_lru(
allocator,
aws_hash_string,
(aws_hash_callback_eq_fn *)aws_string_eq,
s_string_eq,
NULL,
(aws_hash_callback_destroy_fn *)s_aws_s3express_session_destroy,
s_s3express_session_destroy,
s_default_cache_capacity);
AWS_ASSERT(impl->synced_data.cache);

Expand All @@ -989,7 +1006,7 @@ struct aws_s3express_credentials_provider *aws_s3express_credentials_provider_ne
provider->shutdown_complete_callback = options->shutdown_complete_callback;
provider->shutdown_user_data = options->shutdown_user_data;
aws_mutex_init(&impl->synced_data.lock);
aws_ref_count_init(&impl->internal_ref, provider, (aws_simple_completion_callback *)s_finish_provider_destroy);
aws_ref_count_init(&impl->internal_ref, provider, s_finish_provider_destroy_wrap);

/* Init the background refresh task */
impl->bg_refresh_task = aws_mem_calloc(provider->allocator, 1, sizeof(struct aws_task));
Expand Down
6 changes: 5 additions & 1 deletion tests/s3_data_plane_tests.c
Original file line number Diff line number Diff line change
Expand Up @@ -3448,6 +3448,10 @@ void s_failing_pool_destroy(struct aws_s3_buffer_pool *buffer_pool_wrapper) {
aws_mem_release((struct aws_allocator *)buffer_pool_wrapper->impl, buffer_pool_wrapper);
}

static void s_failing_pool_destroy_wrap(void *user_data) {
s_failing_pool_destroy(user_data);
}

struct aws_s3_buffer_pool *s_always_error_buffer_pool_fn(
struct aws_allocator *allocator,
struct aws_s3_buffer_pool_config config,
Expand All @@ -3457,7 +3461,7 @@ struct aws_s3_buffer_pool *s_always_error_buffer_pool_fn(
struct aws_s3_buffer_pool *pool = aws_mem_calloc(allocator, 1, sizeof(struct aws_s3_buffer_pool));
pool->impl = allocator;
pool->vtable = &s_failing_pool_vtable;
aws_ref_count_init(&pool->ref_count, pool, (aws_simple_completion_callback *)s_failing_pool_destroy);
aws_ref_count_init(&pool->ref_count, pool, s_failing_pool_destroy_wrap);

return pool;
}
Expand Down
6 changes: 5 additions & 1 deletion tests/s3_s3express_client_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ struct aws_s3express_client_tester {

static struct aws_s3express_client_tester s_tester;

static void s_credentials_release_wrap(void *value) {
aws_credentials_release(value);
}

static int s_s3express_client_tester_init(struct aws_allocator *allocator) {
s_tester.allocator = allocator;
aws_hash_table_init(
Expand All @@ -44,7 +48,7 @@ static int s_s3express_client_tester_init(struct aws_allocator *allocator) {
aws_hash_string,
aws_hash_callback_string_eq,
aws_hash_callback_string_destroy,
(aws_hash_callback_destroy_fn *)aws_credentials_release);
s_credentials_release_wrap);
aws_atomic_init_int(&s_tester.provider_requests_made, 0);
return AWS_OP_SUCCESS;
}
Expand Down
6 changes: 5 additions & 1 deletion tests/s3_test_input_stream.c
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,10 @@ static void s_aws_s3_test_input_stream_destroy(struct aws_s3_test_input_stream_i
aws_mem_release(test_input_stream->allocator, test_input_stream);
}

static void s_aws_s3_test_input_stream_destroy_wrap(void *user_data) {
s_aws_s3_test_input_stream_destroy(user_data);
}

static struct aws_input_stream_vtable s_aws_s3_test_input_stream_vtable_1 = {
.seek = s_aws_s3_test_input_stream_seek,
.read = s_aws_s3_test_input_stream_read_1,
Expand Down Expand Up @@ -121,7 +125,7 @@ struct aws_input_stream *aws_s3_test_input_stream_new_with_value_type(
aws_ref_count_init(
&test_input_stream->base.ref_count,
test_input_stream,
(aws_simple_completion_callback *)s_aws_s3_test_input_stream_destroy);
s_aws_s3_test_input_stream_destroy_wrap);

struct aws_input_stream *input_stream = &test_input_stream->base;

Expand Down