Skip to content

Commit

Permalink
clean up changes
Browse files Browse the repository at this point in the history
  • Loading branch information
xiazhvera committed Feb 26, 2025
1 parent 5f74137 commit bcf1d23
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 21 deletions.
4 changes: 2 additions & 2 deletions include/aws/io/private/socket_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ struct socket_address {
struct sockaddr_in addr_in;
struct sockaddr_in6 addr_in6;
struct sockaddr_un un_addr;
#ifdef USE_VSOCK
# ifdef USE_VSOCK
struct sockaddr_vm vm_addr;
#endif
# endif
} sock_addr_types;
};
#endif
Expand Down
24 changes: 13 additions & 11 deletions source/darwin/nw_socket.c
Original file line number Diff line number Diff line change
Expand Up @@ -503,7 +503,9 @@ struct read_queue_node {
dispatch_data_t received_data;
struct aws_linked_list_node node;
size_t region_offset;
size_t current_region;
// If we didn't finish reading the received_data, we need to keep track of the region offset that we would
// like to resume with
size_t resume_region;
};

static void s_destroy_read_queue_node(struct read_queue_node *node) {
Expand Down Expand Up @@ -1949,23 +1951,23 @@ static int s_socket_read_fn(struct aws_socket *socket, struct aws_byte_buf *read
(void)region;
(void)offset;

AWS_LOGF_DEBUG(
AWS_LOGF_TRACE(
AWS_LS_IO_SOCKET,
"id=%p handle=%p: dispatch_data_apply: starting read region: %lu, with region offset: %lu and reading region %lu, read buffer %p, with size %lu",
"id=%p handle=%p: Starting read dispatch data region offset: %lu, buffer %p, with size %lu.",
(void *)socket,
socket->io_handle.data.handle,
offset,
read_node->region_offset,
read_node->current_region,
buffer, size);
if (read_node->current_region && offset < read_node->current_region) {
AWS_LOGF_DEBUG(
buffer,
size);

if (read_node->resume_region && offset < read_node->resume_region) {
AWS_LOGF_TRACE(
AWS_LS_IO_SOCKET,
"id=%p handle=%p: dispatch_data_apply: skipped current region : %lu, looking for region: %lu",
"id=%p handle=%p: Skipped dispatch data region region : %lu, looking for region: %lu",
(void *)socket,
socket->io_handle.data.handle,
offset,
read_node->current_region);
read_node->resume_region);
return true;
}
size_t to_copy = aws_min_size(max_to_read, size - read_node->region_offset);
Expand All @@ -1977,7 +1979,7 @@ static int s_socket_read_fn(struct aws_socket *socket, struct aws_byte_buf *read
read_node->region_offset = 0;
return true;
}
read_node->current_region = offset;
read_node->resume_region = offset;
return false;
});

Expand Down
2 changes: 0 additions & 2 deletions source/darwin/secure_transport_tls_channel_handler.c
Original file line number Diff line number Diff line change
Expand Up @@ -682,8 +682,6 @@ static int s_process_read_message(
handler, slot, &outgoing_read_message->message_data, secure_transport_handler->user_data);
}

AWS_LOGF_TRACE(AWS_LS_IO_TLS, "id=%p: bytes read :" PRInSTR, (void *)handler, AWS_BYTE_BUF_PRI(outgoing_read_message->message_data));

if (slot->adj_right) {
if (aws_channel_slot_send_message(slot, outgoing_read_message, AWS_CHANNEL_DIR_READ)) {
aws_mem_release(outgoing_read_message->allocator, outgoing_read_message);
Expand Down
5 changes: 2 additions & 3 deletions source/socket_channel_handler.c
Original file line number Diff line number Diff line change
Expand Up @@ -159,10 +159,9 @@ static void s_do_read(struct socket_handler *socket_handler) {
total_read += read;
AWS_LOGF_TRACE(
AWS_LS_IO_SOCKET_HANDLER,
"id=%p: read %llu from socket: " PRInSTR,
"id=%p: read %llu from socket",
(void *)socket_handler->slot->handler,
(unsigned long long)read,
AWS_BYTE_BUF_PRI(message->message_data));
(unsigned long long)read);

if (aws_channel_slot_send_message(socket_handler->slot, message, AWS_CHANNEL_DIR_READ)) {
last_error = aws_last_error();
Expand Down
5 changes: 2 additions & 3 deletions tests/socket_handler_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -744,12 +744,11 @@ static int s_socket_data_over_multiple_frames_test(struct aws_allocator *allocat
s_socket_common_tester_init(allocator, &c_tester);

// Create a large message that will be split over multiple frames
const size_t total_bytes_to_send_from_server = g_aws_channel_max_fragment_size * 100;
const size_t total_bytes_to_send_from_server = g_aws_channel_max_fragment_size * 1024;
struct aws_byte_buf msg_from_server;
ASSERT_SUCCESS(aws_byte_buf_init(&msg_from_server, allocator, total_bytes_to_send_from_server));
// Seed the random number generator
srand((unsigned int)time(NULL));

srand(0);
// Fill the buffer with random printable ASCII characters
for (size_t i = 0; i < total_bytes_to_send_from_server; ++i) {
char random_char = 32 + (rand() % 95); // Printable ASCII characters range from 32 to 126
Expand Down

0 comments on commit bcf1d23

Please sign in to comment.