Skip to content

Commit

Permalink
read state
Browse files Browse the repository at this point in the history
  • Loading branch information
TingDaoK committed Jul 24, 2024
1 parent 3c9261d commit 2c250e1
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 19 deletions.
2 changes: 1 addition & 1 deletion include/aws/io/private/tls_channel_handler_shared.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ struct aws_tls_channel_handler_shared {
struct aws_crt_statistics_tls stats;
};

enum aws_tls_handler_state {
enum aws_tls_handler_read_state {
AWS_TLS_HANDLER_OPEN,
AWS_TLS_HANDLER_READ_SHUTTING_DOWN,
AWS_TLS_HANDLER_READ_SHUT_DOWN_COMPLETE,
Expand Down
16 changes: 8 additions & 8 deletions source/darwin/secure_transport_tls_channel_handler.c
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ struct secure_transport_handler {
bool negotiation_finished;
bool verify_peer;
bool read_task_pending;
enum aws_tls_handler_state state;
enum aws_tls_handler_read_state read_state;
int delay_shutdown_error_code;
};

Expand Down Expand Up @@ -573,7 +573,7 @@ static void s_initialize_read_delay_shutdown(
" Your application may hang if the read window never opens",
(void *)handler);
}
secure_transport_handler->state = AWS_TLS_HANDLER_READ_SHUTTING_DOWN;
secure_transport_handler->read_state = AWS_TLS_HANDLER_READ_SHUTTING_DOWN;
secure_transport_handler->delay_shutdown_error_code = error_code;
if (!secure_transport_handler->read_task_pending) {
/* Kick off read, in case data arrives with TLS negotiation. Shutdown starts right after negotiation.
Expand Down Expand Up @@ -603,7 +603,7 @@ static int s_handle_shutdown(
* data. */
return AWS_OP_SUCCESS;
}
secure_transport_handler->state = AWS_TLS_HANDLER_READ_SHUT_DOWN_COMPLETE;
secure_transport_handler->read_state = AWS_TLS_HANDLER_READ_SHUT_DOWN_COMPLETE;
} else {
/* Shutdown in write direction */
if (!abort_immediately && error_code != AWS_IO_SOCKET_CLOSED) {
Expand All @@ -626,7 +626,7 @@ static int s_process_read_message(
struct aws_io_message *message) {

struct secure_transport_handler *secure_transport_handler = handler->impl;
if (secure_transport_handler->state == AWS_TLS_HANDLER_READ_SHUT_DOWN_COMPLETE) {
if (secure_transport_handler->read_state == AWS_TLS_HANDLER_READ_SHUT_DOWN_COMPLETE) {
if (message) {
aws_mem_release(message->allocator, message);
}
Expand Down Expand Up @@ -697,7 +697,7 @@ static int s_process_read_message(

switch (status) {
case errSSLWouldBlock:
if (secure_transport_handler->state == AWS_TLS_HANDLER_READ_SHUTTING_DOWN) {
if (secure_transport_handler->read_state == AWS_TLS_HANDLER_READ_SHUTTING_DOWN) {
/* Propagate the shutdown as we blocked now. */
goto shutdown_channel;
} else {
Expand Down Expand Up @@ -728,13 +728,13 @@ static int s_process_read_message(
return AWS_OP_SUCCESS;

shutdown_channel:
if (secure_transport_handler->state == AWS_TLS_HANDLER_READ_SHUTTING_DOWN) {
if (secure_transport_handler->read_state == AWS_TLS_HANDLER_READ_SHUTTING_DOWN) {
if (secure_transport_handler->delay_shutdown_error_code != 0) {
/* Propagate the original error code if it is set. */
shutdown_error_code = secure_transport_handler->delay_shutdown_error_code;
}
/* Continue the shutdown process delayed before. */
secure_transport_handler->state = AWS_TLS_HANDLER_READ_SHUT_DOWN_COMPLETE;
secure_transport_handler->read_state = AWS_TLS_HANDLER_READ_SHUT_DOWN_COMPLETE;
aws_channel_slot_on_handler_shutdown_complete(slot, AWS_CHANNEL_DIR_READ, shutdown_error_code, false);
} else {
/* Starts the shutdown process */
Expand All @@ -755,7 +755,7 @@ static void s_run_read(struct aws_channel_task *task, void *arg, aws_task_status

static int s_increment_read_window(struct aws_channel_handler *handler, struct aws_channel_slot *slot, size_t size) {
struct secure_transport_handler *secure_transport_handler = handler->impl;
if (secure_transport_handler->state == AWS_TLS_HANDLER_READ_SHUT_DOWN_COMPLETE) {
if (secure_transport_handler->read_state == AWS_TLS_HANDLER_READ_SHUT_DOWN_COMPLETE) {
return AWS_OP_SUCCESS;
}

Expand Down
14 changes: 7 additions & 7 deletions source/s2n/s2n_tls_channel_handler.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ struct s2n_handler {
} state;
struct aws_channel_task read_task;
bool read_task_pending;
enum aws_tls_handler_state state;
enum aws_tls_handler_read_state read_state;
int shutdown_error_code;
struct aws_channel_task delayed_shutdown_task;
};
Expand Down Expand Up @@ -521,7 +521,7 @@ static int s_s2n_handler_process_read_message(

struct s2n_handler *s2n_handler = handler->impl;

if (s2n_handler->state == AWS_TLS_HANDLER_READ_SHUT_DOWN_COMPLETE) {
if (s2n_handler->read_state == AWS_TLS_HANDLER_READ_SHUT_DOWN_COMPLETE) {
if (message) {
aws_mem_release(message->allocator, message);
}
Expand Down Expand Up @@ -591,7 +591,7 @@ static int s_s2n_handler_process_read_message(

/* the socket blocked so exit from the loop */
if (s2n_error_get_type(s2n_errno) == S2N_ERR_T_BLOCKED) {
if (s2n_handler->state == AWS_TLS_HANDLER_READ_SHUTTING_DOWN) {
if (s2n_handler->read_state == AWS_TLS_HANDLER_READ_SHUTTING_DOWN) {
/* Propagate the shutdown as we blocked now. */
goto shutdown_channel;
}
Expand Down Expand Up @@ -633,7 +633,7 @@ static int s_s2n_handler_process_read_message(
return AWS_OP_SUCCESS;

shutdown_channel:
if (s2n_handler->state == AWS_TLS_HANDLER_READ_SHUTTING_DOWN) {
if (s2n_handler->read_state == AWS_TLS_HANDLER_READ_SHUTTING_DOWN) {
if (s2n_handler->shutdown_error_code != 0) {
/* Propagate the original error code if it is set. */
shutdown_error_code = s2n_handler->shutdown_error_code;
Expand Down Expand Up @@ -1047,7 +1047,7 @@ static void s_initialize_read_delay_shutdown(
" Your application may hang if the read window never opens",
(void *)handler);
}
s2n_handler->state = AWS_TLS_HANDLER_READ_SHUTTING_DOWN;
s2n_handler->read_state = AWS_TLS_HANDLER_READ_SHUTTING_DOWN;
s2n_handler->shutdown_error_code = error_code;
if (!s2n_handler->read_task_pending) {
/* Kick off read, in case data arrives with TLS negotiation. Shutdown starts right after negotiation.
Expand Down Expand Up @@ -1081,7 +1081,7 @@ static int s_s2n_handler_shutdown(
s_initialize_read_delay_shutdown(handler, slot, error_code);
return AWS_OP_SUCCESS;
}
s2n_handler->state = AWS_TLS_HANDLER_READ_SHUT_DOWN_COMPLETE;
s2n_handler->read_state = AWS_TLS_HANDLER_READ_SHUT_DOWN_COMPLETE;
} else {
/* Shutdown in write direction */
if (!abort_immediately && error_code != AWS_IO_SOCKET_CLOSED) {
Expand All @@ -1106,7 +1106,7 @@ static int s_s2n_handler_increment_read_window(
size_t size) {
(void)size;
struct s2n_handler *s2n_handler = handler->impl;
if (s2n_handler->state == AWS_TLS_HANDLER_READ_SHUT_DOWN_COMPLETE) {
if (s2n_handler->read_state == AWS_TLS_HANDLER_READ_SHUT_DOWN_COMPLETE) {
return AWS_OP_SUCCESS;
}

Expand Down
6 changes: 3 additions & 3 deletions source/windows/secure_channel_tls_handler.c
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ struct secure_channel_handler {
bool verify_peer;
struct aws_channel_task read_task;
bool read_task_pending;
enum aws_tls_handler_state state;
enum aws_tls_handler_state read_state;
int shutdown_error_code;
};

Expand Down Expand Up @@ -1225,7 +1225,7 @@ static int s_process_pending_output_messages(struct aws_channel_handler *handler
sc_handler->state = AWS_TLS_HANDLER_READ_SHUT_DOWN_COMPLETE;
/* Continue the shutdown process delayed before. */
aws_channel_slot_on_handler_shutdown_complete(
sc_handler->slot, AWS_CHANNEL_DIR_READ, sc_handler->delay_shutdown_error_code, false);
sc_handler->slot, AWS_CHANNEL_DIR_READ, sc_handler->shutdown_error_code, false);
}

return AWS_OP_SUCCESS;
Expand Down Expand Up @@ -1567,7 +1567,7 @@ static void s_initialize_read_delay_shutdown(
(void *)handler);
}
sc_handler->state = AWS_TLS_HANDLER_READ_SHUTTING_DOWN;
sc_handler->delay_shutdown_error_code = error_code;
sc_handler->shutdown_error_code = error_code;
if (!sc_handler->read_task_pending) {
/* Kick off read, in case data arrives with TLS negotiation. Shutdown starts right after negotiation.
* Nothing will kick off read in that case. */
Expand Down

0 comments on commit 2c250e1

Please sign in to comment.