Skip to content

Commit

Permalink
validate dispatch loop
Browse files Browse the repository at this point in the history
  • Loading branch information
xiazhvera committed Nov 27, 2024
1 parent 82635e5 commit 3c34a54
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 13 deletions.
19 changes: 10 additions & 9 deletions include/aws/io/private/event_loop_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -118,15 +118,6 @@ typedef struct aws_event_loop *(aws_new_event_loop_fn)(struct aws_allocator *all
const struct aws_event_loop_options *options,
void *new_loop_user_data);

/**
* @internal - Don't use outside of testing.
*
* Return the default event loop type. If the return value is `AWS_ELT_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);

struct aws_event_loop_group {
struct aws_allocator *allocator;
struct aws_array_list event_loops;
Expand Down Expand Up @@ -161,6 +152,16 @@ AWS_IO_API
struct _OVERLAPPED *aws_overlapped_to_windows_overlapped(struct aws_overlapped *overlapped);
#endif /* AWS_ENABLE_IO_COMPLETION_PORTS */

/**
* @internal - Don't use outside of testing.
*
* Return the default event loop type. If the return value is `AWS_ELT_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.
*/
AWS_IO_API
enum aws_event_loop_type aws_event_loop_get_default_type(void);

/**
* Associates an aws_io_handle with the event loop's I/O Completion Port.
*
Expand Down
2 changes: 1 addition & 1 deletion source/darwin/dispatch_queue_event_loop.c
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,7 @@ static void s_run_iteration(void *context) {
*/
static void s_try_schedule_new_iteration(struct dispatch_loop_context *dispatch_loop_context, uint64_t timestamp) {
struct dispatch_loop *dispatch_loop = dispatch_loop_context->io_dispatch_loop;
if (dispatch_loop->synced_data.suspended)
if (!dispatch_loop || dispatch_loop->synced_data.suspended)
return;
if (!s_should_schedule_iteration(&dispatch_loop->synced_data.scheduling_state.scheduled_services, timestamp)) {
return;
Expand Down
3 changes: 0 additions & 3 deletions tests/event_loop_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -179,9 +179,6 @@ static int s_test_event_loop_canceled_tasks_run_in_el_thread(struct aws_allocato
}
ASSERT_INT_EQUALS(AWS_TASK_STATUS_CANCELED, task2_args.status);

// DEBUG: test sleep
aws_thread_current_sleep(3);

return AWS_OP_SUCCESS;
}

Expand Down

0 comments on commit 3c34a54

Please sign in to comment.