Skip to content

Commit

Permalink
update socket api changes for network framework
Browse files Browse the repository at this point in the history
  • Loading branch information
xiazhvera committed Nov 9, 2024
1 parent e613e5d commit 28b7546
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 24 deletions.
21 changes: 0 additions & 21 deletions source/darwin/nw_socket.c
Original file line number Diff line number Diff line change
Expand Up @@ -1587,24 +1587,3 @@ static bool s_socket_is_open_fn(struct aws_socket *socket) {
return nw_socket->last_error == AWS_OP_SUCCESS;
}

void aws_socket_endpoint_init_local_address_for_test(struct aws_socket_endpoint *endpoint) {
struct aws_uuid uuid;
AWS_FATAL_ASSERT(aws_uuid_init(&uuid) == AWS_OP_SUCCESS);
char uuid_str[AWS_UUID_STR_LEN] = {0};
struct aws_byte_buf uuid_buf = aws_byte_buf_from_empty_array(uuid_str, sizeof(uuid_str));
AWS_FATAL_ASSERT(aws_uuid_to_str(&uuid, &uuid_buf) == AWS_OP_SUCCESS);
snprintf(endpoint->address, sizeof(endpoint->address), "testsock" PRInSTR ".local", AWS_BYTE_BUF_PRI(uuid_buf));
}

int aws_socket_get_bound_address(const struct aws_socket *socket, struct aws_socket_endpoint *out_address) {
if (socket->local_endpoint.address[0] == 0) {
AWS_LOGF_ERROR(
AWS_LS_IO_SOCKET,
"id=%p fd=%d: Socket has no local address. Socket must be bound first.",
(void *)socket,
socket->io_handle.data.fd);
return aws_raise_error(AWS_IO_SOCKET_ILLEGAL_OPERATION_FOR_STATE);
}
*out_address = socket->local_endpoint;
return AWS_OP_SUCCESS;
}
5 changes: 5 additions & 0 deletions source/socket.c
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,11 @@ void aws_socket_endpoint_init_local_address_for_test(struct aws_socket_endpoint
struct aws_byte_buf uuid_buf = aws_byte_buf_from_empty_array(uuid_str, sizeof(uuid_str));
AWS_FATAL_ASSERT(aws_uuid_to_str(&uuid, &uuid_buf) == AWS_OP_SUCCESS);

#if defined(WS_USE_APPLE_NETWORK_FRAMEWORK)
snprintf(endpoint->address, sizeof(endpoint->address), "testsock" PRInSTR ".local", AWS_BYTE_BUF_PRI(uuid_buf));
return;
#endif

#if defined(AWS_ENABLE_KQUEUE) || defined(AWS_ENABLE_EPOLL)
snprintf(endpoint->address, sizeof(endpoint->address), "testsock" PRInSTR ".sock", AWS_BYTE_BUF_PRI(uuid_buf));
return;
Expand Down
6 changes: 3 additions & 3 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ add_test_case(io_library_init)
add_test_case(io_library_init_cleanup_init_cleanup)

# Dispatch Queue does not support pipe
if(NOT AWS_EVENT_LOOP_DISPATCH_QUEUE_OVERRIDE)
if(NOT AWS_USE_APPLE_NETWORK_FRAMEWORK)
add_pipe_test_case(pipe_open_close)
add_pipe_test_case(pipe_read_write)
add_pipe_test_case(pipe_read_write_large_buffer)
Expand All @@ -39,7 +39,7 @@ add_test_case(event_loop_canceled_tasks_run_in_el_thread)

if(USE_IO_COMPLETION_PORTS)
add_test_case(event_loop_completion_events)
elseif(NOT AWS_EVENT_LOOP_DISPATCH_QUEUE_OVERRIDE) # Dispatch Queue does not support pipe
elseif(NOT AWS_USE_APPLE_NETWORK_FRAMEWORK) # Dispatch Queue does not support pipe
add_test_case(event_loop_subscribe_unsubscribe)
add_test_case(event_loop_writable_event_on_subscribe)
add_test_case(event_loop_no_readable_event_before_write)
Expand Down Expand Up @@ -83,7 +83,7 @@ add_test_case(cleanup_in_write_cb_doesnt_explode)
add_test_case(sock_write_cb_is_async)
add_test_case(socket_validate_port)

if(NOT AWS_EVENT_LOOP_DISPATCH_QUEUE_OVERRIDE)
if(NOT AWS_USE_APPLE_NETWORK_FRAMEWORK)
# Apple Network Framework does not support bind+connect
add_test_case(udp_bind_connect_communication)
# The read/write will always run a different thread for Apple Network Framework
Expand Down

0 comments on commit 28b7546

Please sign in to comment.