Skip to content

Commit

Permalink
add close_notify as raw SSL_shutdown
Browse files Browse the repository at this point in the history
this is needed for sending EOF, aka one-way shutdown.
  • Loading branch information
Christopher Zimmermann committed Jan 6, 2022
1 parent c6aea13 commit 28557b1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/lwt_ssl.ml
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,13 @@ let ssl_shutdown (fd, s) =

let shutdown (fd, _) cmd = Lwt_unix.shutdown fd cmd

let close_notify = function
| (_, Plain) as s ->
shutdown s Unix.SHUTDOWN_SEND;
Lwt.return_true
| (fd, SSL s) ->
repeat_call fd (fun () -> Ssl.close_notify s)

let close (fd, _) = Lwt_unix.close fd

let abort (fd, _) = Lwt_unix.abort fd
Expand Down
1 change: 1 addition & 0 deletions src/lwt_ssl.mli
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ val close : socket -> unit Lwt.t
val in_channel_of_descr : ?buffer:Lwt_bytes.t -> socket -> Lwt_io.input_channel
val out_channel_of_descr : ?buffer:Lwt_bytes.t -> socket -> Lwt_io.output_channel

val close_notify : socket -> bool Lwt.t
val ssl_shutdown : socket -> unit Lwt.t

val abort : socket -> exn -> unit
Expand Down

0 comments on commit 28557b1

Please sign in to comment.