-
Notifications
You must be signed in to change notification settings - Fork 11
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
Is there a way to have Server_connection pass the fd to the request_hander? #139
Comments
it's fairly easy to do this, though it's unsafe. here's a simplified version with eio: let request_handler (_fd: _ Eio.Net.stream_socket) (_ : Eio.Net.Sockaddr.stream) { Gluten.reqd= _; _ } =
assert false
;;
(* ... *)
let handler fd =
Server.create_connection_handler
~request_handler:(request_handler fd)
~error_handler
(* ... *)
while true do
Eio.Net.accept_fork socket ~sw ~on_error:log_connection_error (fun client_sock client_addr ->
handler client_sock client_addr client_sock)
done;
|
Thank you. On a basic level, I have it working. However, is the expansion still safe w.r.t. side effects for SSL? let request_handler = wrap_handler true error_handler handler in
let error_handler = Error_handler.httpaf error_handler in
fun client_address unix_socket tls_endpoint ->
Httpaf_lwt_unix.Server.SSL.create_connection_handler
?config:None
~request_handler:(request_handler unix_socket)
~error_handler
client_address
tls_endpoint and likewise for ocaml-h2? |
I believe you can rely on this, since the connection establishment happens at |
Alright, thank you! This is probably the most questionable part of Dream at this point, together with the |
I don't know if "it works". Referring to my initial response:
it depends what you do with the socket. httpun / gluten / etc guarantee the correct lifecycle for the connection (and consequently, the socket) – that's not the case if you're accessing it directly. |
Dumping the fd number on Unix. |
I understood your intent, but I wanted to leave it written down for the next person looking for this answer. |
This would help with ocaml/ocaml.org#2676 (comment). I don't see a way to pass the fd at the moment, and it doesn't seem to be available through
Reqd.t
orRequest.t
.The text was updated successfully, but these errors were encountered: