Skip to content

Commit

Permalink
upgrade: fix lwt runtime
Browse files Browse the repository at this point in the history
The future returned by the ugprade handler will dicatate when the fd
will be closed.
  • Loading branch information
seliopou committed Oct 18, 2019
1 parent cc50482 commit cf62e96
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
7 changes: 3 additions & 4 deletions lwt-unix/httpaf_lwt_unix.ml
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,10 @@ module Server = struct
type t =
| Ignore
| Raise
| Handle of (Lwt_unix.file_descr -> Httpaf.Request.t -> Httpaf.Response.t -> unit)
| Handle of (Lwt_unix.file_descr -> Httpaf.Request.t -> Httpaf.Response.t -> unit Lwt.t)

let to_handler = function
| Ignore -> (fun socket _request _response -> Lwt.async (fun () -> Lwt_unix.close socket))
| Ignore -> (fun socket _request _response -> Lwt_unix.close socket)
| Raise ->
(fun socket _request _response ->
Lwt.async (fun () -> Lwt_unix.close socket);
Expand Down Expand Up @@ -188,8 +188,7 @@ module Server = struct
Server_connection.report_write_result connection result;
write_loop_step ()
| `Upgrade(request, response) ->
upgrade_handler socket request response;
Lwt.return_unit
upgrade_handler socket request response
| `Yield ->
Server_connection.yield_writer connection write_loop;
Lwt.return_unit
Expand Down
2 changes: 1 addition & 1 deletion lwt-unix/httpaf_lwt_unix.mli
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ module Server : sig
type t =
| Ignore
| Raise
| Handle of (Lwt_unix.file_descr -> Httpaf.Request.t -> Httpaf.Response.t -> unit)
| Handle of (Lwt_unix.file_descr -> Httpaf.Request.t -> Httpaf.Response.t -> unit Lwt.t)
end

val create_connection_handler
Expand Down

0 comments on commit cf62e96

Please sign in to comment.