-
Notifications
You must be signed in to change notification settings - Fork 48
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix building on OpenBSD, allow one-way shutdown #63
Conversation
I don't care about the close_notify change so much anymore, but please merge the compatibility changes to support LibreSSL. |
src/ssl.mli
Outdated
@@ -418,7 +418,11 @@ val accept : socket -> unit | |||
(** Flush an SSL connection. *) | |||
val flush : socket -> unit | |||
|
|||
(** Close an SSL connection. *) | |||
(** send close notify to the peer. This is SSL_shutdown(3) *) | |||
val close_notify : socket -> int |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The API follows the general convention that the return value is never exposed, because it is quite meaningless in OCaml. A boolean indicating whehter the shutdown is finished or not (and exceptions in other cases) would be better.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I changed it to bool.
src/ssl.mli
Outdated
@@ -418,7 +418,11 @@ val accept : socket -> unit | |||
(** Flush an SSL connection. *) | |||
val flush : socket -> unit | |||
|
|||
(** Close an SSL connection. *) | |||
(** send close notify to the peer. This is SSL_shutdown(3) *) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(** send close notify to the peer. This is SSL_shutdown(3) *) | |
(** Send close notify to the peer. This is SSL_shutdown(3). *) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
422a115
to
9bad44b
Compare
this is needed for sending EOF, aka one-way shutdown.
|
||
let rec shutdown sock = | ||
if not (close_notify sock) | ||
then shutdown sock |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be close_notify
to prevent unbounded recursion?
then shutdown sock | |
then close_notify sock |
CHANGES: - Add `Ssl.close_notify` to perform a one-way shutdown (savonet/ocaml-ssl#63, savonet/ocaml-ssl#96).
EOF
over ssl you need to be able to initiate a one-way shutdownSee also ocsigen/lwt_ssl#2 and mirage/ocaml-conduit#319