From eac617786f28be612ebdf10c487baf33e75e9006 Mon Sep 17 00:00:00 2001 From: Bikal Lem <gbikal@gmail.com> Date: Wed, 14 Dec 2022 16:45:19 +0000 Subject: [PATCH] tls-eio: fix handle_tls --- eio/tls_eio.ml | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/eio/tls_eio.ml b/eio/tls_eio.ml index f641fadb..54d9d14e 100644 --- a/eio/tls_eio.ml +++ b/eio/tls_eio.ml @@ -27,18 +27,16 @@ module Raw = struct match Tls.Engine.handle_tls t.tls data with | Ok ( state, `Response resp, `Data application_data ) -> begin match state with - | `Ok tls -> - t.tls <- tls ; - Option.iter (write_t t) resp ; - Eio.Mutex.unlock t.mutex ; - application_data + | `Ok tls -> t.tls <- tls | `Eof -> (* received "close_notify" alert from peer so shutdown receving data - from the peer socket. https://www.rfc-editor.org/rfc/rfc8446#section-6.1 *) - Eio.Flow.shutdown t.flow `Receive ; - None + from the peer socket. https://www.rfc-editor.org/rfc/rfc8446#section-6.1 *) + Eio.Flow.shutdown t.flow `Receive | `Alert a -> raise (Tls_alert a) - end + end ; + Option.iter (write_t t) resp ; + Eio.Mutex.unlock t.mutex ; + application_data | Error (failure, `Response resp) -> write_t t resp ; raise (Tls_failure failure)