Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: Michael Graeb <[email protected]>
  • Loading branch information
xiazhvera and graebm authored Nov 11, 2024
1 parent 6f1984c commit 8d84d11
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 11 deletions.
2 changes: 1 addition & 1 deletion include/aws/io/socket.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
13 changes: 4 additions & 9 deletions source/event_loop.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,23 +57,17 @@ struct aws_event_loop *aws_event_loop_new_with_options(
switch (type) {
case AWS_ELT_EPOLL:
return aws_event_loop_new_epoll_with_options(alloc, options);
break;
case AWS_ELT_IOCP:
return aws_event_loop_new_iocp_with_options(alloc, options);
break;
case AWS_ELT_KQUEUE:
return aws_event_loop_new_kqueue_with_options(alloc, options);
break;
case AWS_ELT_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) {
Expand Down Expand Up @@ -547,10 +541,11 @@ int aws_event_loop_current_clock_time(struct aws_event_loop *event_loop, uint64_
* AWS_ELT_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)) {
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_ELT_PLATFORM_DEFAULT;
}
s_default_event_loop_type_override = default_type_override;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion source/socket.c
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ int aws_socket_init(struct aws_socket *socket, struct aws_allocator *alloc, cons

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
Expand Down

0 comments on commit 8d84d11

Please sign in to comment.