Skip to content

Commit 1762f83

Browse files
Add user data to pool factory (#529)
1 parent 29ceb35 commit 1762f83

File tree

4 files changed

+10
-3
lines changed

4 files changed

+10
-3
lines changed

include/aws/s3/s3_buffer_pool.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,8 @@ struct aws_s3_buffer_pool_config {
141141
* by logging failure reason, returning null and raising aws_error.
142142
*/
143143
typedef struct aws_s3_buffer_pool *(aws_s3_buffer_pool_factory_fn)(struct aws_allocator *allocator,
144-
struct aws_s3_buffer_pool_config config);
144+
struct aws_s3_buffer_pool_config config,
145+
void *user_data);
145146

146147
AWS_EXTERN_C_END
147148
AWS_POP_SANE_WARNING_LEVEL

include/aws/s3/s3_client.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -606,6 +606,9 @@ struct aws_s3_client_config {
606606
* if not set creates default implementation of the buffer pool.
607607
*/
608608
aws_s3_buffer_pool_factory_fn *buffer_pool_factory_fn;
609+
610+
/* User data thats passed into pool factory. */
611+
void *buffer_pool_user_data;
609612
};
610613

611614
struct aws_s3_checksum_config {

source/s3_client.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,8 @@ struct aws_s3_client *aws_s3_client_new(
367367
};
368368

369369
if (client_config->buffer_pool_factory_fn) {
370-
client->buffer_pool = client_config->buffer_pool_factory_fn(allocator, buffer_pool_config);
370+
client->buffer_pool =
371+
client_config->buffer_pool_factory_fn(allocator, buffer_pool_config, client_config->buffer_pool_user_data);
371372
} else {
372373

373374
client->buffer_pool = aws_s3_default_buffer_pool_new(allocator, buffer_pool_config);

tests/s3_data_plane_tests.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3375,8 +3375,10 @@ void s_failing_pool_destroy(struct aws_s3_buffer_pool *buffer_pool_wrapper) {
33753375

33763376
struct aws_s3_buffer_pool *s_always_error_buffer_pool_fn(
33773377
struct aws_allocator *allocator,
3378-
struct aws_s3_buffer_pool_config config) {
3378+
struct aws_s3_buffer_pool_config config,
3379+
void *user_data) {
33793380
(void)config;
3381+
(void)user_data;
33803382
struct aws_s3_buffer_pool *pool = aws_mem_calloc(allocator, 1, sizeof(struct aws_s3_buffer_pool));
33813383
pool->impl = allocator;
33823384
pool->vtable = &s_failing_pool_vtable;

0 commit comments

Comments
 (0)