diff --git a/CMakeLists.txt b/CMakeLists.txt index fb14f7f35..94df410ac 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -123,7 +123,6 @@ elseif (APPLE) message(FATAL_ERROR "Network framework not found") endif () - #No choice on TLS for apple, darwinssl will always be used. list(APPEND PLATFORM_LIBS "-framework Security -framework Network") list(APPEND EVENT_LOOP_DEFINES "DISPATCH_QUEUE") @@ -220,10 +219,7 @@ if (USE_VSOCK) endif() if (AWS_USE_APPLE_NETWORK_FRAMEWORK) - target_compile_definitions(${PROJECT_NAME} PRIVATE "-DAWS_USE_APPLE_NETWORK_FRAMEWORK") - option(AWS_USE_APPLE_NETWORK_FRAMEWORK - "Use apple network framework as default event loop and socket options." - ON) + target_compile_definitions(${PROJECT_NAME} PUBLIC "-DAWS_USE_APPLE_NETWORK_FRAMEWORK") endif() target_include_directories(${PROJECT_NAME} PUBLIC diff --git a/include/aws/io/event_loop.h b/include/aws/io/event_loop.h index 441432cc7..32f38d005 100644 --- a/include/aws/io/event_loop.h +++ b/include/aws/io/event_loop.h @@ -12,25 +12,58 @@ AWS_PUSH_SANE_WARNING_LEVEL struct aws_event_loop; struct aws_event_loop_group; +struct aws_event_loop_options; struct aws_shutdown_callback_options; struct aws_task; /** - * Event Loop Type. If set to `AWS_ELT_PLATFORM_DEFAULT`, the event loop will automatically use the platform’s default. + * @internal + */ +typedef void(aws_event_loop_on_event_fn)( + struct aws_event_loop *event_loop, + struct aws_io_handle *handle, + int events, + void *user_data); + +/** + * @internal + */ +struct aws_event_loop_vtable { + void (*destroy)(struct aws_event_loop *event_loop); + int (*run)(struct aws_event_loop *event_loop); + int (*stop)(struct aws_event_loop *event_loop); + int (*wait_for_stop_completion)(struct aws_event_loop *event_loop); + void (*schedule_task_now)(struct aws_event_loop *event_loop, struct aws_task *task); + void (*schedule_task_future)(struct aws_event_loop *event_loop, struct aws_task *task, uint64_t run_at_nanos); + void (*cancel_task)(struct aws_event_loop *event_loop, struct aws_task *task); + int (*connect_to_io_completion_port)(struct aws_event_loop *event_loop, struct aws_io_handle *handle); + int (*subscribe_to_io_events)( + struct aws_event_loop *event_loop, + struct aws_io_handle *handle, + int events, + aws_event_loop_on_event_fn *on_event, + void *user_data); + int (*unsubscribe_from_io_events)(struct aws_event_loop *event_loop, struct aws_io_handle *handle); + void (*free_io_event_resources)(void *user_data); + bool (*is_on_callers_thread)(struct aws_event_loop *event_loop); +}; + +/** + * Event Loop Type. If set to `AWS_EVENT_LOOP_PLATFORM_DEFAULT`, the event loop will automatically use the platform’s default. * * Default Event Loop Type - * Linux | AWS_ELT_EPOLL - * Windows | AWS_ELT_IOCP - * BSD Variants| AWS_ELT_KQUEUE - * MacOS | AWS_ELT_KQUEUE - * iOS | AWS_ELT_DISPATCH_QUEUE + * Linux | AWS_EVENT_LOOP_EPOLL + * Windows | AWS_EVENT_LOOP_IOCP + * BSD Variants| AWS_EVENT_LOOP_KQUEUE + * MacOS | AWS_EVENT_LOOP_KQUEUE + * iOS | AWS_EVENT_LOOP_DISPATCH_QUEUE */ enum aws_event_loop_type { - AWS_ELT_PLATFORM_DEFAULT = 0, - AWS_ELT_EPOLL, - AWS_ELT_IOCP, - AWS_ELT_KQUEUE, - AWS_ELT_DISPATCH_QUEUE, + AWS_EVENT_LOOP_PLATFORM_DEFAULT = 0, + AWS_EVENT_LOOP_EPOLL, + AWS_EVENT_LOOP_IOCP, + AWS_EVENT_LOOP_KQUEUE, + AWS_EVENT_LOOP_DISPATCH_QUEUE, }; /** @@ -45,7 +78,7 @@ struct aws_event_loop_group_options { uint16_t loop_count; /** - * Event loop type. If the event loop type is set to AWS_ELT_PLATFORM_DEFAULT, the + * Event loop type. If the event loop type is set to AWS_EVENT_LOOP_PLATFORM_DEFAULT, the * creation function will automatically use the platform’s default event loop type. */ enum aws_event_loop_type type; @@ -58,7 +91,7 @@ struct aws_event_loop_group_options { /** * Optional configuration to control how the event loop group's threads bind to CPU groups */ - uint16_t *cpu_group; + const uint16_t *cpu_group; /** * Override for the clock function that event loops should use. Defaults to the system's high resolution @@ -122,7 +155,7 @@ bool aws_event_loop_thread_is_callers_thread(struct aws_event_loop *event_loop); * Gets the current timestamp for the event loop's clock, in nanoseconds. This function is thread-safe. */ AWS_IO_API -int aws_event_loop_current_clock_time(struct aws_event_loop *event_loop, uint64_t *time_nanos); +int aws_event_loop_current_clock_time(const struct aws_event_loop *event_loop, uint64_t *time_nanos); /** * Creation function for event loop groups. @@ -157,7 +190,7 @@ struct aws_event_loop *aws_event_loop_group_get_loop_at(struct aws_event_loop_gr * Gets the number of event loops managed by an event loop group. */ AWS_IO_API -size_t aws_event_loop_group_get_loop_count(struct aws_event_loop_group *el_group); +size_t aws_event_loop_group_get_loop_count(const struct aws_event_loop_group *el_group); /** * Fetches the next loop for use. The purpose is to enable load balancing across loops. You should not depend on how @@ -168,10 +201,6 @@ AWS_IO_API struct aws_event_loop *aws_event_loop_group_get_next_loop(struct aws_event_loop_group *el_group); /** - * Initializes an event loop group with platform defaults. If max_threads == 0, then the - * loop count will be the number of available processors on the machine / 2 (to exclude hyper-threads). - * Otherwise, max_threads will be the number of event loops in the group. - * * @deprecated - use aws_event_loop_group_new() instead */ AWS_IO_API @@ -180,15 +209,7 @@ struct aws_event_loop_group *aws_event_loop_group_new_default( uint16_t max_threads, const struct aws_shutdown_callback_options *shutdown_options); -/** Creates an event loop group, with clock, number of loops to manage, the function to call for creating a new - * event loop, and also pins all loops to hw threads on the same cpu_group (e.g. NUMA nodes). Note: - * If el_count exceeds the number of hw threads in the cpu_group it will be clamped to the number of hw threads - * on the assumption that if you care about NUMA, you don't want hyper-threads doing your IO and you especially - * don't want IO on a different node. - * - * If max_threads == 0, then the - * loop count will be the number of available processors in the cpu_group / 2 (to exclude hyper-threads) - * +/** * @deprecated - use aws_event_loop_group_new() instead */ AWS_IO_API @@ -198,6 +219,48 @@ struct aws_event_loop_group *aws_event_loop_group_new_default_pinned_to_cpu_grou uint16_t cpu_group, const struct aws_shutdown_callback_options *shutdown_options); +/** + * @internal - Don't use outside of testing. + * + * Returns the opaque internal user data of an event loop. Can be cast into a specific implementation by + * privileged consumers. + */ +AWS_IO_API +void *aws_event_loop_get_impl(struct aws_event_loop *event_loop); + +/** + * @internal - Don't use outside of testing. + * + * Initializes the base structure used by all event loop implementations with test-oriented overrides. + */ +AWS_IO_API +struct aws_event_loop *aws_event_loop_new_base( + struct aws_allocator *allocator, + aws_io_clock_fn *clock, + struct aws_event_loop_vtable *vtable, + void *impl); + +/** + * @internal - Don't use outside of testing. + * + * Common cleanup code for all implementations. + * This is only called from the *destroy() function of event loop implementations. + */ +AWS_IO_API +void aws_event_loop_clean_up_base(struct aws_event_loop *event_loop); + +/** + * @internal - Don't use outside of testing. + * + * Invokes the destroy() fn for the event loop implementation. + * If the event loop is still in a running state, this function will block waiting on the event loop to shutdown. + * If you do not want this function to block, call aws_event_loop_stop() manually first. + * If the event loop is shared by multiple threads then destroy must be called by exactly one thread. All other threads + * must ensure their API calls to the event loop happen-before the call to destroy. + */ +AWS_IO_API +void aws_event_loop_destroy(struct aws_event_loop *event_loop); + AWS_EXTERN_C_END AWS_POP_SANE_WARNING_LEVEL diff --git a/include/aws/io/private/event_loop_impl.h b/include/aws/io/private/event_loop_impl.h index ec8c70eda..ac5318a3c 100644 --- a/include/aws/io/private/event_loop_impl.h +++ b/include/aws/io/private/event_loop_impl.h @@ -11,6 +11,7 @@ #include #include #include +#include AWS_PUSH_SANE_WARNING_LEVEL @@ -57,12 +58,6 @@ struct aws_overlapped { void *user_data; }; -typedef void(aws_event_loop_on_event_fn)( - struct aws_event_loop *event_loop, - struct aws_io_handle *handle, - int events, - void *user_data); - enum aws_io_event_type { AWS_IO_EVENT_TYPE_READABLE = 1, AWS_IO_EVENT_TYPE_WRITABLE = 2, @@ -71,26 +66,6 @@ enum aws_io_event_type { AWS_IO_EVENT_TYPE_ERROR = 16, }; -struct aws_event_loop_vtable { - void (*destroy)(struct aws_event_loop *event_loop); - int (*run)(struct aws_event_loop *event_loop); - int (*stop)(struct aws_event_loop *event_loop); - int (*wait_for_stop_completion)(struct aws_event_loop *event_loop); - void (*schedule_task_now)(struct aws_event_loop *event_loop, struct aws_task *task); - void (*schedule_task_future)(struct aws_event_loop *event_loop, struct aws_task *task, uint64_t run_at_nanos); - void (*cancel_task)(struct aws_event_loop *event_loop, struct aws_task *task); - int (*connect_to_io_completion_port)(struct aws_event_loop *event_loop, struct aws_io_handle *handle); - int (*subscribe_to_io_events)( - struct aws_event_loop *event_loop, - struct aws_io_handle *handle, - int events, - aws_event_loop_on_event_fn *on_event, - void *user_data); - int (*unsubscribe_from_io_events)(struct aws_event_loop *event_loop, struct aws_io_handle *handle); - void (*free_io_event_resources)(void *user_data); - bool (*is_on_callers_thread)(struct aws_event_loop *event_loop); -}; - struct aws_event_loop { struct aws_event_loop_vtable *vtable; struct aws_allocator *alloc; @@ -117,25 +92,21 @@ struct aws_event_loop_options { struct aws_thread_options *thread_options; /** - * Event loop type. If the event loop type is set to AWS_ELT_PLATFORM_DEFAULT, the + * Event loop type. If the event loop type is set to AWS_EVENT_LOOP_PLATFORM_DEFAULT, the * creation function will automatically use the platform’s default event loop type. */ enum aws_event_loop_type type; }; -AWS_IO_API struct aws_event_loop *aws_event_loop_new_iocp_with_options( struct aws_allocator *alloc, const struct aws_event_loop_options *options); -AWS_IO_API struct aws_event_loop *aws_event_loop_new_dispatch_queue_with_options( struct aws_allocator *alloc, const struct aws_event_loop_options *options); -AWS_IO_API struct aws_event_loop *aws_event_loop_new_kqueue_with_options( struct aws_allocator *alloc, const struct aws_event_loop_options *options); -AWS_IO_API struct aws_event_loop *aws_event_loop_new_epoll_with_options( struct aws_allocator *alloc, const struct aws_event_loop_options *options); @@ -217,31 +188,9 @@ struct aws_event_loop *aws_event_loop_new_default(struct aws_allocator *alloc, a /** * Creates an instance of the default event loop implementation for the current architecture and operating system using * extendable options. - * - * Please note the event loop type defined in the options will be ignored. - */ -AWS_IO_API -struct aws_event_loop *aws_event_loop_new_default_with_options( - struct aws_allocator *alloc, - const struct aws_event_loop_options *options); - -/** - * Creates an instance of the event loop implementation from the options. - */ -AWS_IO_API -struct aws_event_loop *aws_event_loop_new_with_options( - struct aws_allocator *alloc, - const struct aws_event_loop_options *options); - -/** - * Invokes the destroy() fn for the event loop implementation. - * If the event loop is still in a running state, this function will block waiting on the event loop to shutdown. - * If you do not want this function to block, call aws_event_loop_stop() manually first. - * If the event loop is shared by multiple threads then destroy must be called by exactly one thread. All other threads - * must ensure their API calls to the event loop happen-before the call to destroy. */ AWS_IO_API -void aws_event_loop_destroy(struct aws_event_loop *event_loop); +struct aws_event_loop *aws_event_loop_new(struct aws_allocator *alloc, const struct aws_event_loop_options *options); /** * Initializes common event-loop data structures. @@ -250,13 +199,6 @@ void aws_event_loop_destroy(struct aws_event_loop *event_loop); AWS_IO_API int aws_event_loop_init_base(struct aws_event_loop *event_loop, struct aws_allocator *alloc, aws_io_clock_fn *clock); -/** - * Common cleanup code for all implementations. - * This is only called from the *destroy() function of event loop implementations. - */ -AWS_IO_API -void aws_event_loop_clean_up_base(struct aws_event_loop *event_loop); - /** * Fetches an object from the event-loop's data store. Key will be taken as the memory address of the memory pointed to * by key. This function is not thread safe and should be called inside the event-loop's thread. diff --git a/include/aws/io/socket.h b/include/aws/io/socket.h index f7ac432ec..eddc259ab 100644 --- a/include/aws/io/socket.h +++ b/include/aws/io/socket.h @@ -32,21 +32,21 @@ enum aws_socket_type { }; /** - * Socket Implementation type. Decides which socket implementation is used. If set to `AWS_SIT_PLATFORM_DEFAULT`, it - * will automatically use the platform’s default. + * Socket Implementation type. Decides which socket implementation is used. If set to + * `AWS_SOCKET_IMPL_PLATFORM_DEFAULT`, it will automatically use the platform’s default. * * PLATFORM DEFAULT SOCKET IMPLEMENTATION TYPE - * Linux | AWS_SIT_POSIX - * Windows | AWS_SIT_WINSOCK - * BSD Variants| AWS_SIT_POSIX - * MacOS | AWS_SIT_POSIX - * iOS | AWS_SIT_APPLE_NETWORK_FRAMEWORK + * Linux | AWS_SOCKET_IMPL_POSIX + * Windows | AWS_SOCKET_IMPL_WINSOCK + * BSD Variants| AWS_SOCKET_IMPL_POSIX + * MacOS | AWS_SOCKET_IMPL_POSIX + * iOS | AWS_SOCKET_IMPL_APPLE_NETWORK_FRAMEWORK */ enum aws_socket_impl_type { - AWS_SIT_PLATFORM_DEFAULT = 0, - AWS_SIT_POSIX, - AWS_SIT_WINSOCK, - AWS_SIT_APPLE_NETWORK_FRAMEWORK, + AWS_SOCKET_IMPL_PLATFORM_DEFAULT = 0, + AWS_SOCKET_IMPL_POSIX, + AWS_SOCKET_IMPL_WINSOCK, + AWS_SOCKET_IMPL_APPLE_NETWORK_FRAMEWORK, }; #define AWS_NETWORK_INTERFACE_NAME_MAX 16 @@ -99,7 +99,7 @@ typedef void(aws_socket_on_connection_result_fn)(struct aws_socket *socket, int * A user may want to call aws_socket_set_options() on the new socket if different options are desired. * * new_socket is not yet assigned to an event-loop. The user should call aws_socket_assign_to_event_loop() before - * performing IO operations. The user is responsible to releasing the socket memory after use. + * performing IO operations. The user must call `aws_socket_release()` when they're done with the socket, to free it. * * When error_code is AWS_ERROR_SUCCESS, new_socket is the recently accepted connection. * If error_code is non-zero, an error occurred and you should aws_socket_close() the socket. @@ -116,7 +116,8 @@ typedef void(aws_socket_on_accept_result_fn)( * Callback for when the data passed to a call to aws_socket_write() has either completed or failed. * On success, error_code will be AWS_ERROR_SUCCESS. * - * socket is possible to be a NULL pointer in the callback. + * `socket` may be NULL in the callback if the socket is released and cleaned up before a callback is triggered. + * by the system I/O handler, */ typedef void( aws_socket_on_write_completed_fn)(struct aws_socket *socket, int error_code, size_t bytes_written, void *user_data); @@ -205,17 +206,17 @@ aws_ms_fn_ptr aws_winsock_get_connectex_fn(void); aws_ms_fn_ptr aws_winsock_get_acceptex_fn(void); #endif -AWS_IO_API int aws_socket_init_posix( +int aws_socket_init_posix( struct aws_socket *socket, struct aws_allocator *alloc, const struct aws_socket_options *options); -AWS_IO_API int aws_socket_init_winsock( +int aws_socket_init_winsock( struct aws_socket *socket, struct aws_allocator *alloc, const struct aws_socket_options *options); -AWS_IO_API int aws_socket_init_apple_nw_socket( +int aws_socket_init_apple_nw_socket( struct aws_socket *socket, struct aws_allocator *alloc, const struct aws_socket_options *options); diff --git a/include/aws/io/tls_channel_handler.h b/include/aws/io/tls_channel_handler.h index f44335b12..087b333a3 100644 --- a/include/aws/io/tls_channel_handler.h +++ b/include/aws/io/tls_channel_handler.h @@ -34,14 +34,14 @@ enum aws_tls_cipher_pref { /* Deprecated */ AWS_IO_TLS_CIPHER_PREF_KMS_PQ_TLSv1_0_2020_02 = 3, /* Deprecated */ AWS_IO_TLS_CIPHER_PREF_KMS_PQ_SIKE_TLSv1_0_2020_02 = 4, /* Deprecated */ AWS_IO_TLS_CIPHER_PREF_KMS_PQ_TLSv1_0_2020_07 = 5, + /* Deprecated */ AWS_IO_TLS_CIPHER_PREF_PQ_TLSv1_0_2021_05 = 6, /* - * This TLS cipher preference list contains post-quantum key exchange algorithms that have been submitted to NIST - * for potential future standardization. Support for this preference list, or PQ algorithms present in it, may be - * removed at any time in the future. PQ algorithms in this preference list will be used in hybrid mode, and always - * combined with a classical ECDHE key exchange. + * This TLS cipher preference list contains post-quantum key exchange algorithms that have been standardized by + * NIST. PQ algorithms in this preference list will be used in hybrid mode, and always combined with a classical + * ECDHE key exchange. */ - AWS_IO_TLS_CIPHER_PREF_PQ_TLSv1_0_2021_05 = 6, + AWS_IO_TLS_CIPHER_PREF_PQ_TLSV1_2_2024_10 = 7, AWS_IO_TLS_CIPHER_PREF_END_RANGE = 0xFFFF }; diff --git a/include/aws/testing/io_testing_channel.h b/include/aws/testing/io_testing_channel.h index 501c3f6bf..8fa118ca4 100644 --- a/include/aws/testing/io_testing_channel.h +++ b/include/aws/testing/io_testing_channel.h @@ -9,11 +9,11 @@ #include #include #include -#include #include #include struct testing_loop { + struct aws_allocator *allocator; struct aws_task_scheduler scheduler; bool mock_on_callers_thread; }; @@ -34,7 +34,7 @@ static int s_testing_loop_wait_for_stop_completion(struct aws_event_loop *event_ } static void s_testing_loop_schedule_task_now(struct aws_event_loop *event_loop, struct aws_task *task) { - struct testing_loop *testing_loop = event_loop->impl_data; + struct testing_loop *testing_loop = (struct testing_loop *)aws_event_loop_get_impl(event_loop); aws_task_scheduler_schedule_now(&testing_loop->scheduler, task); } @@ -43,26 +43,27 @@ static void s_testing_loop_schedule_task_future( struct aws_task *task, uint64_t run_at_nanos) { - struct testing_loop *testing_loop = event_loop->impl_data; + struct testing_loop *testing_loop = (struct testing_loop *)aws_event_loop_get_impl(event_loop); aws_task_scheduler_schedule_future(&testing_loop->scheduler, task, run_at_nanos); } static void s_testing_loop_cancel_task(struct aws_event_loop *event_loop, struct aws_task *task) { - struct testing_loop *testing_loop = event_loop->impl_data; + struct testing_loop *testing_loop = (struct testing_loop *)aws_event_loop_get_impl(event_loop); aws_task_scheduler_cancel_task(&testing_loop->scheduler, task); } static bool s_testing_loop_is_on_callers_thread(struct aws_event_loop *event_loop) { - struct testing_loop *testing_loop = event_loop->impl_data; + struct testing_loop *testing_loop = (struct testing_loop *)aws_event_loop_get_impl(event_loop); return testing_loop->mock_on_callers_thread; } static void s_testing_loop_destroy(struct aws_event_loop *event_loop) { - struct testing_loop *testing_loop = event_loop->impl_data; + struct testing_loop *testing_loop = (struct testing_loop *)aws_event_loop_get_impl(event_loop); + struct aws_allocator *allocator = testing_loop->allocator; aws_task_scheduler_clean_up(&testing_loop->scheduler); - aws_mem_release(event_loop->alloc, testing_loop); + aws_mem_release(allocator, testing_loop); aws_event_loop_clean_up_base(event_loop); - aws_mem_release(event_loop->alloc, event_loop); + aws_mem_release(allocator, event_loop); } static struct aws_event_loop_vtable s_testing_loop_vtable = { @@ -77,16 +78,14 @@ static struct aws_event_loop_vtable s_testing_loop_vtable = { }; static struct aws_event_loop *s_testing_loop_new(struct aws_allocator *allocator, aws_io_clock_fn clock) { - struct aws_event_loop *event_loop = aws_mem_acquire(allocator, sizeof(struct aws_event_loop)); - aws_event_loop_init_base(event_loop, allocator, clock); + struct testing_loop *testing_loop = + (struct testing_loop *)aws_mem_calloc(allocator, 1, sizeof(struct testing_loop)); - struct testing_loop *testing_loop = aws_mem_calloc(allocator, 1, sizeof(struct testing_loop)); aws_task_scheduler_init(&testing_loop->scheduler, allocator); testing_loop->mock_on_callers_thread = true; - event_loop->impl_data = testing_loop; - event_loop->vtable = &s_testing_loop_vtable; + testing_loop->allocator = allocator; - return event_loop; + return aws_event_loop_new_base(allocator, clock, &s_testing_loop_vtable, testing_loop); } typedef void(testing_channel_handler_on_shutdown_fn)( @@ -114,7 +113,7 @@ static int s_testing_channel_handler_process_read_message( (void)slot; (void)message; - struct testing_channel_handler *testing_handler = handler->impl; + struct testing_channel_handler *testing_handler = (struct testing_channel_handler *)handler->impl; aws_linked_list_push_back(&testing_handler->messages, &message->queueing_handle); return AWS_OP_SUCCESS; } @@ -125,7 +124,7 @@ static int s_testing_channel_handler_process_write_message( struct aws_io_message *message) { (void)slot; - struct testing_channel_handler *testing_handler = handler->impl; + struct testing_channel_handler *testing_handler = (struct testing_channel_handler *)handler->impl; aws_linked_list_push_back(&testing_handler->messages, &message->queueing_handle); /* Invoke completion callback if this is the left-most handler */ @@ -143,7 +142,7 @@ static int s_testing_channel_handler_increment_read_window( size_t size) { (void)slot; - struct testing_channel_handler *testing_handler = handler->impl; + struct testing_channel_handler *testing_handler = (struct testing_channel_handler *)handler->impl; testing_handler->latest_window_update = size; return AWS_OP_SUCCESS; } @@ -155,7 +154,7 @@ static int s_testing_channel_handler_shutdown( int error_code, bool free_scarce_resources_immediately) { - struct testing_channel_handler *testing_handler = handler->impl; + struct testing_channel_handler *testing_handler = (struct testing_channel_handler *)handler->impl; /* If user has registered a callback, invoke it */ if (testing_handler->on_shutdown) { @@ -184,7 +183,7 @@ static int s_testing_channel_handler_shutdown( } static size_t s_testing_channel_handler_initial_window_size(struct aws_channel_handler *handler) { - struct testing_channel_handler *testing_handler = handler->impl; + struct testing_channel_handler *testing_handler = (struct testing_channel_handler *)handler->impl; return testing_handler->initial_window; } @@ -194,7 +193,7 @@ static size_t s_testing_channel_handler_message_overhead(struct aws_channel_hand } static void s_testing_channel_handler_destroy(struct aws_channel_handler *handler) { - struct testing_channel_handler *testing_handler = handler->impl; + struct testing_channel_handler *testing_handler = (struct testing_channel_handler *)handler->impl; while (!aws_linked_list_empty(&testing_handler->messages)) { struct aws_linked_list_node *node = aws_linked_list_pop_front(&testing_handler->messages); @@ -207,7 +206,7 @@ static void s_testing_channel_handler_destroy(struct aws_channel_handler *handle } static void s_testing_channel_handler_reset_statistics(struct aws_channel_handler *handler) { - struct testing_channel_handler *testing_handler = handler->impl; + struct testing_channel_handler *testing_handler = (struct testing_channel_handler *)handler->impl; aws_crt_statistics_socket_reset(&testing_handler->stats); } @@ -215,7 +214,7 @@ static void s_testing_channel_handler_reset_statistics(struct aws_channel_handle static void s_testing_channel_handler_gather_statistics( struct aws_channel_handler *handler, struct aws_array_list *stats) { - struct testing_channel_handler *testing_handler = handler->impl; + struct testing_channel_handler *testing_handler = (struct testing_channel_handler *)handler->impl; void *stats_base = &testing_handler->stats; aws_array_list_push_back(stats, &stats_base); @@ -236,9 +235,10 @@ static struct aws_channel_handler_vtable s_testing_channel_handler_vtable = { static struct aws_channel_handler *s_new_testing_channel_handler( struct aws_allocator *allocator, size_t initial_window) { - struct aws_channel_handler *handler = aws_mem_calloc(allocator, 1, sizeof(struct aws_channel_handler)); + struct aws_channel_handler *handler = + (struct aws_channel_handler *)aws_mem_calloc(allocator, 1, sizeof(struct aws_channel_handler)); struct testing_channel_handler *testing_handler = - aws_mem_calloc(allocator, 1, sizeof(struct testing_channel_handler)); + (struct testing_channel_handler *)aws_mem_calloc(allocator, 1, sizeof(struct testing_channel_handler)); aws_linked_list_init(&testing_handler->messages); testing_handler->initial_window = initial_window; testing_handler->latest_window_update = 0; @@ -271,14 +271,14 @@ struct testing_channel { static void s_testing_channel_on_setup_completed(struct aws_channel *channel, int error_code, void *user_data) { (void)channel; (void)error_code; - struct testing_channel *testing = user_data; + struct testing_channel *testing = (struct testing_channel *)user_data; testing->channel_setup_completed = true; } static void s_testing_channel_on_shutdown_completed(struct aws_channel *channel, int error_code, void *user_data) { (void)channel; (void)error_code; - struct testing_channel *testing = user_data; + struct testing_channel *testing = (struct testing_channel *)user_data; testing->channel_shutdown_completed = true; testing->channel_shutdown_error_code = error_code; @@ -394,7 +394,7 @@ static inline int testing_channel_init( AWS_ZERO_STRUCT(*testing); testing->loop = s_testing_loop_new(allocator, options->clock_fn); - testing->loop_impl = testing->loop->impl_data; + testing->loop_impl = (struct testing_loop *)aws_event_loop_get_impl(testing->loop); struct aws_channel_options args = { .on_setup_completed = s_testing_channel_on_setup_completed, @@ -412,8 +412,9 @@ static inline int testing_channel_init( ASSERT_TRUE(testing->channel_setup_completed); testing->left_handler_slot = aws_channel_slot_new(testing->channel); - struct aws_channel_handler *handler = s_new_testing_channel_handler(allocator, 16 * 1024); - testing->left_handler_impl = handler->impl; + struct aws_channel_handler *handler = + (struct aws_channel_handler *)s_new_testing_channel_handler(allocator, 16 * 1024); + testing->left_handler_impl = (struct testing_channel_handler *)handler->impl; ASSERT_SUCCESS(aws_channel_slot_set_handler(testing->left_handler_slot, handler)); return AWS_OP_SUCCESS; @@ -446,7 +447,7 @@ static inline int testing_channel_install_downstream_handler(struct testing_chan struct aws_channel_handler *handler = s_new_testing_channel_handler(testing->left_handler_slot->alloc, initial_window); ASSERT_NOT_NULL(handler); - testing->right_handler_impl = handler->impl; + testing->right_handler_impl = (struct testing_channel_handler *)handler->impl; ASSERT_SUCCESS(aws_channel_slot_set_handler(testing->right_handler_slot, handler)); return AWS_OP_SUCCESS; diff --git a/source/event_loop.c b/source/event_loop.c index 1a5103d5d..8d1ba9802 100644 --- a/source/event_loop.c +++ b/source/event_loop.c @@ -5,6 +5,7 @@ #include +#include #include #include @@ -14,37 +15,27 @@ #include #include -static enum aws_event_loop_type s_default_event_loop_type_override = AWS_ELT_PLATFORM_DEFAULT; +#ifdef AWS_USE_APPLE_NETWORK_FRAMEWORK +static enum aws_event_loop_type s_default_event_loop_type_override = AWS_EVENT_LOOP_DISPATCH_QUEUE; +#else +static enum aws_event_loop_type s_default_event_loop_type_override = AWS_EVENT_LOOP_PLATFORM_DEFAULT; +#endif struct aws_event_loop *aws_event_loop_new_default(struct aws_allocator *alloc, aws_io_clock_fn *clock) { struct aws_event_loop_options options = { .thread_options = NULL, .clock = clock, - .type = AWS_ELT_PLATFORM_DEFAULT, + .type = AWS_EVENT_LOOP_PLATFORM_DEFAULT, }; - return aws_event_loop_new_with_options(alloc, &options); -} - -struct aws_event_loop *aws_event_loop_new_default_with_options( - struct aws_allocator *alloc, - const struct aws_event_loop_options *options) { - struct aws_event_loop_options local_options = { - .thread_options = options->thread_options, - .clock = options->clock, - .type = AWS_ELT_PLATFORM_DEFAULT, - }; - - return aws_event_loop_new_with_options(alloc, &local_options); + return aws_event_loop_new(alloc, &options); } static int aws_event_loop_type_validate_platform(enum aws_event_loop_type type); -struct aws_event_loop *aws_event_loop_new_with_options( - struct aws_allocator *alloc, - const struct aws_event_loop_options *options) { +struct aws_event_loop *aws_event_loop_new(struct aws_allocator *alloc, const struct aws_event_loop_options *options) { enum aws_event_loop_type type = options->type; - if (type == AWS_ELT_PLATFORM_DEFAULT) { + if (type == AWS_EVENT_LOOP_PLATFORM_DEFAULT) { type = aws_event_loop_get_default_type(); } @@ -54,25 +45,19 @@ struct aws_event_loop *aws_event_loop_new_with_options( } switch (type) { - case AWS_ELT_EPOLL: + case AWS_EVENT_LOOP_EPOLL: return aws_event_loop_new_epoll_with_options(alloc, options); - break; - case AWS_ELT_IOCP: + case AWS_EVENT_LOOP_IOCP: return aws_event_loop_new_iocp_with_options(alloc, options); - break; - case AWS_ELT_KQUEUE: + case AWS_EVENT_LOOP_KQUEUE: return aws_event_loop_new_kqueue_with_options(alloc, options); - break; - case AWS_ELT_DISPATCH_QUEUE: + case AWS_EVENT_LOOP_DISPATCH_QUEUE: return aws_event_loop_new_dispatch_queue_with_options(alloc, options); - break; default: AWS_LOGF_DEBUG(AWS_LS_IO_EVENT_LOOP, "Invalid event loop type on the platform."); aws_raise_error(AWS_ERROR_PLATFORM_NOT_SUPPORTED); - break; + return NULL; } - - return NULL; } static void s_event_loop_group_thread_exit(void *user_data) { @@ -246,7 +231,7 @@ static struct aws_event_loop *s_default_new_event_loop( void *user_data) { (void)user_data; - return aws_event_loop_new_default_with_options(allocator, options); + return aws_event_loop_new(allocator, options); } struct aws_event_loop_group *aws_event_loop_group_new( @@ -270,7 +255,7 @@ void aws_event_loop_group_release(struct aws_event_loop_group *el_group) { } } -size_t aws_event_loop_group_get_loop_count(struct aws_event_loop_group *el_group) { +size_t aws_event_loop_group_get_loop_count(const struct aws_event_loop_group *el_group) { return aws_array_list_length(&el_group->event_loops); } @@ -534,34 +519,77 @@ bool aws_event_loop_thread_is_callers_thread(struct aws_event_loop *event_loop) return event_loop->vtable->is_on_callers_thread(event_loop); } -int aws_event_loop_current_clock_time(struct aws_event_loop *event_loop, uint64_t *time_nanos) { +int aws_event_loop_current_clock_time(const struct aws_event_loop *event_loop, uint64_t *time_nanos) { AWS_ASSERT(event_loop->clock); return event_loop->clock(time_nanos); } +struct aws_event_loop_group *aws_event_loop_group_new_default( + struct aws_allocator *alloc, + uint16_t max_threads, + const struct aws_shutdown_callback_options *shutdown_options) { + + struct aws_event_loop_group_options elg_options = { + .loop_count = max_threads, + .shutdown_options = shutdown_options, + }; + + return aws_event_loop_group_new(alloc, &elg_options); +} + +struct aws_event_loop_group *aws_event_loop_group_new_default_pinned_to_cpu_group( + struct aws_allocator *alloc, + uint16_t max_threads, + uint16_t cpu_group, + const struct aws_shutdown_callback_options *shutdown_options) { + + struct aws_event_loop_group_options elg_options = { + .loop_count = max_threads, + .shutdown_options = shutdown_options, + .cpu_group = &cpu_group, + }; + + return aws_event_loop_group_new(alloc, &elg_options); +} + +void *aws_event_loop_get_impl(struct aws_event_loop *event_loop) { + return event_loop->impl_data; +} + +struct aws_event_loop *aws_event_loop_new_base( + struct aws_allocator *allocator, + aws_io_clock_fn *clock, + struct aws_event_loop_vtable *vtable, + void *impl) { + struct aws_event_loop *event_loop = aws_mem_acquire(allocator, sizeof(struct aws_event_loop)); + aws_event_loop_init_base(event_loop, allocator, clock); + event_loop->impl_data = impl; + event_loop->vtable = vtable; + + return event_loop; +} + /** * Override default event loop type. Only used internally in tests. * * If the defined type is not supported on the current platform, the event loop type would reset to - * AWS_ELT_PLATFORM_DEFAULT. + * AWS_EVENT_LOOP_PLATFORM_DEFAULT. */ void aws_event_loop_override_default_type(enum aws_event_loop_type default_type_override) { - if (aws_event_loop_type_validate_platform(default_type_override)) { - s_default_event_loop_type_override = AWS_ELT_PLATFORM_DEFAULT; + if (aws_event_loop_type_validate_platform(default_type_override) == AWS_OP_SUCCESS) { + s_default_event_loop_type_override = default_type_override; + } else { + s_default_event_loop_type_override = AWS_EVENT_LOOP_PLATFORM_DEFAULT; } - s_default_event_loop_type_override = default_type_override; } /** - * Return the default event loop type. If the return value is `AWS_ELT_PLATFORM_DEFAULT`, the function failed to + * Return the default event loop type. If the return value is `AWS_EVENT_LOOP_PLATFORM_DEFAULT`, the function failed to * retrieve the default type value. * If `aws_event_loop_override_default_type` has been called, return the override default type. */ -enum aws_event_loop_type aws_event_loop_get_default_type(void) { -#ifdef AWS_USE_APPLE_NETWORK_FRAMEWORK - aws_event_loop_override_default_type(AWS_ELT_DISPATCH_QUEUE); -#endif // AWS_USE_APPLE_NETWORK_FRAMEWORK - if (s_default_event_loop_type_override != AWS_ELT_PLATFORM_DEFAULT) { +static enum aws_event_loop_type aws_event_loop_get_default_type(void) { + if (s_default_event_loop_type_override != AWS_EVENT_LOOP_PLATFORM_DEFAULT) { return s_default_event_loop_type_override; } /** @@ -569,42 +597,40 @@ enum aws_event_loop_type aws_event_loop_get_default_type(void) { * definition was declared in aws-c-common. We probably do not want to introduce extra dependency here. */ #ifdef AWS_ENABLE_KQUEUE - return AWS_ELT_KQUEUE; + return AWS_EVENT_LOOP_KQUEUE; #endif #ifdef AWS_ENABLE_DISPATCH_QUEUE - return AWS_ELT_DISPATCH_QUEUE; + return AWS_EVENT_LOOP_DISPATCH_QUEUE; #endif #ifdef AWS_ENABLE_EPOLL - return AWS_ELT_EPOLL; + return AWS_EVENT_LOOP_EPOLL; #endif #ifdef AWS_OS_WINDOWS - return AWS_ELT_IOCP; -#else - return AWS_ELT_PLATFORM_DEFAULT; + return AWS_EVENT_LOOP_IOCP; #endif } static int aws_event_loop_type_validate_platform(enum aws_event_loop_type type) { switch (type) { - case AWS_ELT_EPOLL: + case AWS_EVENT_LOOP_EPOLL: #ifndef AWS_ENABLE_EPOLL AWS_LOGF_DEBUG(AWS_LS_IO_EVENT_LOOP, "Event loop type EPOLL is not supported on the platform."); return aws_raise_error(AWS_ERROR_PLATFORM_NOT_SUPPORTED); #endif // AWS_ENABLE_EPOLL break; - case AWS_ELT_IOCP: + case AWS_EVENT_LOOP_IOCP: #ifndef AWS_ENABLE_IO_COMPLETION_PORTS AWS_LOGF_DEBUG(AWS_LS_IO_EVENT_LOOP, "Event loop type IOCP is not supported on the platform."); return aws_raise_error(AWS_ERROR_PLATFORM_NOT_SUPPORTED); #endif // AWS_ENABLE_IO_COMPLETION_PORTS break; - case AWS_ELT_KQUEUE: + case AWS_EVENT_LOOP_KQUEUE: #ifndef AWS_ENABLE_KQUEUE AWS_LOGF_DEBUG(AWS_LS_IO_EVENT_LOOP, "Event loop type KQUEUE is not supported on the platform."); return aws_raise_error(AWS_ERROR_PLATFORM_NOT_SUPPORTED); #endif // AWS_ENABLE_KQUEUE break; - case AWS_ELT_DISPATCH_QUEUE: + case AWS_EVENT_LOOP_DISPATCH_QUEUE: #ifndef AWS_ENABLE_DISPATCH_QUEUE AWS_LOGF_DEBUG(AWS_LS_IO_EVENT_LOOP, "Event loop type Dispatch Queue is not supported on the platform."); return aws_raise_error(AWS_ERROR_PLATFORM_NOT_SUPPORTED); @@ -627,6 +653,7 @@ struct aws_event_loop *aws_event_loop_new_dispatch_queue_with_options( AWS_ASSERT(0); AWS_LOGF_DEBUG(AWS_LS_IO_EVENT_LOOP, "Dispatch Queue is not supported on the platform"); + aws_raise_error(AWS_ERROR_PLATFORM_NOT_SUPPORTED); return NULL; } #endif // AWS_ENABLE_DISPATCH_QUEUE @@ -640,6 +667,7 @@ struct aws_event_loop *aws_event_loop_new_iocp_with_options( AWS_ASSERT(0); AWS_LOGF_DEBUG(AWS_LS_IO_EVENT_LOOP, "IOCP is not supported on the platform"); + aws_raise_error(AWS_ERROR_PLATFORM_NOT_SUPPORTED); return NULL; } #endif // AWS_ENABLE_IO_COMPLETION_PORTS @@ -653,6 +681,7 @@ struct aws_event_loop *aws_event_loop_new_kqueue_with_options( AWS_ASSERT(0); AWS_LOGF_DEBUG(AWS_LS_IO_EVENT_LOOP, "Kqueue is not supported on the platform"); + aws_raise_error(AWS_ERROR_PLATFORM_NOT_SUPPORTED); return NULL; } #endif // AWS_ENABLE_EPOLL @@ -669,31 +698,3 @@ struct aws_event_loop *aws_event_loop_new_epoll_with_options( return NULL; } #endif // AWS_ENABLE_KQUEUE - -struct aws_event_loop_group *aws_event_loop_group_new_default( - struct aws_allocator *alloc, - uint16_t max_threads, - const struct aws_shutdown_callback_options *shutdown_options) { - - struct aws_event_loop_group_options elg_options = { - .loop_count = max_threads, - .shutdown_options = shutdown_options, - }; - - return aws_event_loop_group_new(alloc, &elg_options); -} - -struct aws_event_loop_group *aws_event_loop_group_new_default_pinned_to_cpu_group( - struct aws_allocator *alloc, - uint16_t max_threads, - uint16_t cpu_group, - const struct aws_shutdown_callback_options *shutdown_options) { - - struct aws_event_loop_group_options elg_options = { - .loop_count = max_threads, - .shutdown_options = shutdown_options, - .cpu_group = &cpu_group, - }; - - return aws_event_loop_group_new(alloc, &elg_options); -} diff --git a/source/exponential_backoff_retry_strategy.c b/source/exponential_backoff_retry_strategy.c index f256c0126..2110cbd46 100644 --- a/source/exponential_backoff_retry_strategy.c +++ b/source/exponential_backoff_retry_strategy.c @@ -10,8 +10,8 @@ #include #include #include +#include #include -#include #include diff --git a/source/s2n/s2n_tls_channel_handler.c b/source/s2n/s2n_tls_channel_handler.c index 8326543e8..af8fbd834 100644 --- a/source/s2n/s2n_tls_channel_handler.c +++ b/source/s2n/s2n_tls_channel_handler.c @@ -270,6 +270,8 @@ bool aws_tls_is_cipher_pref_supported(enum aws_tls_cipher_pref cipher_pref) { #ifndef ANDROID case AWS_IO_TLS_CIPHER_PREF_PQ_TLSv1_0_2021_05: return true; + case AWS_IO_TLS_CIPHER_PREF_PQ_TLSV1_2_2024_10: + return true; #endif default: @@ -1536,6 +1538,9 @@ static struct aws_tls_ctx *s_tls_ctx_new( case AWS_IO_TLS_CIPHER_PREF_PQ_TLSv1_0_2021_05: security_policy = "PQ-TLS-1-0-2021-05-26"; break; + case AWS_IO_TLS_CIPHER_PREF_PQ_TLSV1_2_2024_10: + security_policy = "AWS-CRT-SDK-TLSv1.2-2023-PQ"; + break; default: AWS_LOGF_ERROR(AWS_LS_IO_TLS, "Unrecognized TLS Cipher Preference: %d", options->cipher_pref); aws_raise_error(AWS_IO_TLS_CIPHER_PREF_UNSUPPORTED); diff --git a/source/socket.c b/source/socket.c index f373e23fc..5d691767f 100644 --- a/source/socket.c +++ b/source/socket.c @@ -110,31 +110,29 @@ int aws_socket_init(struct aws_socket *socket, struct aws_allocator *alloc, cons // 1. get socket type & validate type is avliable the platform enum aws_socket_impl_type type = options->impl_type; - if (type == AWS_SIT_PLATFORM_DEFAULT) { + if (type == AWS_SOCKET_IMPL_PLATFORM_DEFAULT) { type = aws_socket_get_default_impl_type(); } if (aws_socket_impl_type_validate_platform(type)) { AWS_LOGF_DEBUG(AWS_LS_IO_SOCKET, "Invalid event loop type on the platform."); - return AWS_ERROR_PLATFORM_NOT_SUPPORTED; + return aws_raise_error(AWS_ERROR_PLATFORM_NOT_SUPPORTED); } // 2. setup vtable based on socket type switch (type) { - case AWS_SIT_POSIX: + case AWS_SOCKET_IMPL_POSIX: return aws_socket_init_posix(socket, alloc, options); - break; - case AWS_SIT_WINSOCK: + case AWS_SOCKET_IMPL_WINSOCK: return aws_socket_init_winsock(socket, alloc, options); - break; - case AWS_SIT_APPLE_NETWORK_FRAMEWORK: + case AWS_SOCKET_IMPL_APPLE_NETWORK_FRAMEWORK: + // Apple Network Framework is not implemented yet. We should not use it yet. + AWS_ASSERT(false && "Invalid socket implementation on platform."); return aws_socket_init_apple_nw_socket(socket, alloc, options); - break; default: - break; + AWS_ASSERT(false && "Invalid socket implementation on platform."); + return aws_raise_error(AWS_ERROR_PLATFORM_NOT_SUPPORTED); } - AWS_ASSERT(false && "Invalid socket implementation on platform."); - return AWS_ERROR_PLATFORM_NOT_SUPPORTED; } int aws_socket_get_bound_address(const struct aws_socket *socket, struct aws_socket_endpoint *out_address) { @@ -175,16 +173,16 @@ void aws_socket_endpoint_init_local_address_for_test(struct aws_socket_endpoint } /** - * Return the default socket implementation type. If the return value is `AWS_SIT_PLATFORM_DEFAULT`, the function failed - * to retrieve the default type value. + * Return the default socket implementation type. If the return value is `AWS_SOCKET_IMPL_PLATFORM_DEFAULT`, the + * function failed to retrieve the default type value. */ static enum aws_socket_impl_type aws_socket_get_default_impl_type(void) { - enum aws_socket_impl_type type = AWS_SIT_PLATFORM_DEFAULT; + enum aws_socket_impl_type type = AWS_SOCKET_IMPL_PLATFORM_DEFAULT; // override default socket #ifdef AWS_USE_APPLE_NETWORK_FRAMEWORK - type = AWS_SIT_APPLE_NETWORK_FRAMEWORK; + type = AWS_SOCKET_IMPL_APPLE_NETWORK_FRAMEWORK; #endif // AWS_USE_APPLE_NETWORK_FRAMEWORK - if (type != AWS_SIT_PLATFORM_DEFAULT) { + if (type != AWS_SOCKET_IMPL_PLATFORM_DEFAULT) { return type; } /** @@ -192,33 +190,33 @@ static enum aws_socket_impl_type aws_socket_get_default_impl_type(void) { * definition was declared in aws-c-common. We probably do not want to introduce extra dependency here. */ #if defined(AWS_ENABLE_KQUEUE) || defined(AWS_ENABLE_EPOLL) - return AWS_SIT_POSIX; + return AWS_SOCKET_IMPL_POSIX; #endif #ifdef AWS_ENABLE_DISPATCH_QUEUE - return AWS_SIT_APPLE_NETWORK_FRAMEWORK; + return AWS_SOCKET_IMPL_APPLE_NETWORK_FRAMEWORK; #endif #ifdef AWS_ENABLE_IO_COMPLETION_PORTS - return AWS_SIT_WINSOCK; + return AWS_SOCKET_IMPL_WINSOCK; #else - return AWS_SIT_PLATFORM_DEFAULT; + return AWS_SOCKET_IMPL_PLATFORM_DEFAULT; #endif } static int aws_socket_impl_type_validate_platform(enum aws_socket_impl_type type) { switch (type) { - case AWS_SIT_POSIX: + case AWS_SOCKET_IMPL_POSIX: #if !defined(AWS_ENABLE_EPOLL) && !defined(AWS_ENABLE_KQUEUE) AWS_LOGF_DEBUG(AWS_LS_IO_SOCKET, "Posix socket is not supported on the platform."); return aws_raise_error(AWS_ERROR_PLATFORM_NOT_SUPPORTED); -#endif // AWS_SIT_POSIX +#endif // AWS_SOCKET_IMPL_POSIX break; - case AWS_SIT_WINSOCK: + case AWS_SOCKET_IMPL_WINSOCK: #ifndef AWS_ENABLE_IO_COMPLETION_PORTS AWS_LOGF_DEBUG(AWS_LS_IO_SOCKET, "WINSOCK is not supported on the platform."); return aws_raise_error(AWS_ERROR_PLATFORM_NOT_SUPPORTED); #endif // AWS_ENABLE_IO_COMPLETION_PORTS break; - case AWS_SIT_APPLE_NETWORK_FRAMEWORK: + case AWS_SOCKET_IMPL_APPLE_NETWORK_FRAMEWORK: #ifndef AWS_ENABLE_DISPATCH_QUEUE AWS_LOGF_DEBUG(AWS_LS_IO_SOCKET, "Apple Network Framework is not supported on the platform."); return aws_raise_error(AWS_ERROR_PLATFORM_NOT_SUPPORTED); diff --git a/tests/event_loop_test.c b/tests/event_loop_test.c index 97b3bafd5..3bd5829b9 100644 --- a/tests/event_loop_test.c +++ b/tests/event_loop_test.c @@ -1089,10 +1089,12 @@ static int test_numa_aware_event_loop_group_setup_and_shutdown(struct aws_alloca size_t cpus_for_group = aws_get_cpu_count_for_group(0); size_t el_count = 1; - /* pass UINT16_MAX here to check the boundary conditions on numa cpu detection. It should never create more threads - * than hw cpus available */ uint16_t cpu_group = 0; struct aws_event_loop_group_options elg_options = { + /* + * pass UINT16_MAX here to check the boundary conditions on numa cpu detection. It should never create more + * threads than hw cpus available + */ .loop_count = UINT16_MAX, .cpu_group = &cpu_group, }; diff --git a/tests/socket_handler_test.c b/tests/socket_handler_test.c index 6067b80b6..1f301bfee 100644 --- a/tests/socket_handler_test.c +++ b/tests/socket_handler_test.c @@ -60,7 +60,9 @@ static int s_socket_common_tester_init(struct aws_allocator *allocator, struct s AWS_ZERO_STRUCT(*tester); aws_io_library_init(allocator); - struct aws_event_loop_group_options elg_options = {.loop_count = 1}; + struct aws_event_loop_group_options elg_options = { + .loop_count = 0, + }; tester->el_group = aws_event_loop_group_new(allocator, &elg_options); struct aws_host_resolver_default_options resolver_options = { @@ -992,7 +994,7 @@ static struct aws_event_loop *s_default_new_event_loop( void *user_data) { (void)user_data; - return aws_event_loop_new_default_with_options(allocator, options); + return aws_event_loop_new(allocator, options); } static int s_statistic_test_clock_fn(uint64_t *timestamp) { diff --git a/tests/standard_retry_test.c b/tests/standard_retry_test.c index 3811e7937..11991a3e0 100644 --- a/tests/standard_retry_test.c +++ b/tests/standard_retry_test.c @@ -8,7 +8,7 @@ #include #include -#include +#include #include diff --git a/tests/tls_handler_test.c b/tests/tls_handler_test.c index 7b1a68c32..f943c3371 100644 --- a/tests/tls_handler_test.c +++ b/tests/tls_handler_test.c @@ -1890,7 +1890,7 @@ static struct aws_event_loop *s_default_new_event_loop( void *user_data) { (void)user_data; - return aws_event_loop_new_default_with_options(allocator, options); + return aws_event_loop_new(allocator, options); } static int s_statistic_test_clock_fn(uint64_t *timestamp) {