diff --git a/source/darwin/dispatch_queue_event_loop.c b/source/darwin/dispatch_queue_event_loop.c index d4c25abf2..58c1bf1f3 100644 --- a/source/darwin/dispatch_queue_event_loop.c +++ b/source/darwin/dispatch_queue_event_loop.c @@ -311,12 +311,13 @@ struct aws_event_loop *aws_event_loop_new_with_dispatch_queue( struct dispatch_loop_context *dispatch_loop_context = aws_mem_calloc(alloc, 1, sizeof(struct dispatch_loop_context)); - aws_ref_count_init(&dispatch_loop_context->ref_count, dispatch_loop_context, s_dispatch_loop_context_destroy); dispatch_loop_context->allocator = alloc; + aws_ref_count_init(&dispatch_loop_context->ref_count, dispatch_loop_context, s_dispatch_loop_context_destroy); dispatch_loop->context = dispatch_loop_context; - aws_rw_lock_init(&dispatch_loop_context->lock); dispatch_loop_context->io_dispatch_loop = dispatch_loop; + aws_rw_lock_init(&dispatch_loop_context->lock); + aws_mutex_init(&dispatch_loop_context->scheduling_state.services_lock); if (aws_priority_queue_init_dynamic( &dispatch_loop_context->scheduling_state.scheduled_services,