Skip to content

Commit

Permalink
Make sure to send alerts upon shutdown when free_scarce_resources isn… (
Browse files Browse the repository at this point in the history
#152)

* Make sure to send alerts upon shutdown when free_scarce_resources isn't specified.

* This isn't perfect, but at least check the socket isn't closed before attempting to do the alert.
  • Loading branch information
JonathanHenson authored Jun 20, 2019
1 parent e156b6b commit d86357c
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion source/darwin/secure_transport_tls_channel_handler.c
Original file line number Diff line number Diff line change
Expand Up @@ -516,7 +516,7 @@ static int s_handle_shutdown(
struct secure_transport_handler *secure_transport_handler = handler->impl;

if (dir == AWS_CHANNEL_DIR_WRITE) {
if (!error_code) {
if (!abort_immediately && error_code != AWS_IO_SOCKET_CLOSED) {
AWS_LOGF_TRACE(AWS_LS_IO_TLS, "id=%p: shutting down write direction.", (void *)handler);
SSLClose(secure_transport_handler->ctx);
}
Expand Down
2 changes: 1 addition & 1 deletion source/s2n/s2n_tls_channel_handler.c
Original file line number Diff line number Diff line change
Expand Up @@ -560,7 +560,7 @@ static int s_s2n_handler_shutdown(
struct s2n_handler *s2n_handler = (struct s2n_handler *)handler->impl;

if (dir == AWS_CHANNEL_DIR_WRITE) {
if (!error_code) {
if (!abort_immediately && error_code != AWS_IO_SOCKET_CLOSED) {
AWS_LOGF_DEBUG(AWS_LS_IO_TLS, "id=%p: Shutting down write direction", (void *)handler)
s2n_blocked_status blocked;
/* make a best effort, but the channel is going away after this run, so.... you only get one shot anyways */
Expand Down
5 changes: 3 additions & 2 deletions source/windows/secure_channel_tls_handler.c
Original file line number Diff line number Diff line change
Expand Up @@ -1389,7 +1389,7 @@ static int s_handler_shutdown(
struct secure_channel_handler *sc_handler = handler->impl;

if (dir == AWS_CHANNEL_DIR_WRITE) {
if (!error_code) {
if (!abort_immediately && error_code != AWS_IO_SOCKET_CLOSED) {
AWS_LOGF_DEBUG(AWS_LS_IO_TLS, "id=%p: Shutting down the write direction", (void *)handler)

/* send a TLS alert. */
Expand All @@ -1413,7 +1413,8 @@ static int s_handler_shutdown(

if (status != SEC_E_OK) {
aws_raise_error(AWS_IO_SYS_CALL_FAILURE);
return aws_channel_slot_on_handler_shutdown_complete(slot, dir, AWS_IO_SYS_CALL_FAILURE, true);
return aws_channel_slot_on_handler_shutdown_complete(
slot, dir, AWS_IO_SYS_CALL_FAILURE, abort_immediately);
}

SecBuffer output_buffer = {
Expand Down

0 comments on commit d86357c

Please sign in to comment.