This commit is contained in:
parent
aa2ff7b2f0
commit
2f3113f55d
11742 changed files with 1223940 additions and 0 deletions
5
unikernel/duniverse/faraday/lwt_unix/dune
Normal file
5
unikernel/duniverse/faraday/lwt_unix/dune
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
(library
|
||||
(name faraday_lwt_unix)
|
||||
(public_name faraday-lwt-unix)
|
||||
(libraries faraday lwt lwt.unix faraday-lwt)
|
||||
(flags (:standard -safe-string)))
|
||||
20
unikernel/duniverse/faraday/lwt_unix/faraday_lwt_unix.ml
Normal file
20
unikernel/duniverse/faraday/lwt_unix/faraday_lwt_unix.ml
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
include Faraday_lwt
|
||||
|
||||
open Lwt.Infix
|
||||
|
||||
let writev_of_fd fd =
|
||||
fun iovecs ->
|
||||
let lwt_iovecs = Lwt_unix.IO_vectors.create () in
|
||||
iovecs |> List.iter (fun {Faraday.buffer; off; len} ->
|
||||
Lwt_unix.IO_vectors.append_bigarray lwt_iovecs buffer off len);
|
||||
|
||||
Lwt.catch
|
||||
(fun () ->
|
||||
Lwt_unix.writev fd lwt_iovecs
|
||||
>|= fun n -> `Ok n)
|
||||
(function
|
||||
| Unix.Unix_error (Unix.EBADF, "check_descriptor", _)
|
||||
| Unix.Unix_error (Unix.EPIPE, _, _) ->
|
||||
Lwt.return `Closed
|
||||
| exn ->
|
||||
Lwt.fail exn)
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
open Faraday
|
||||
|
||||
|
||||
include module type of Faraday_lwt
|
||||
|
||||
val writev_of_fd
|
||||
: Lwt_unix.file_descr
|
||||
-> bigstring iovec list -> [ `Ok of int | `Closed ] Lwt.t
|
||||
Loading…
Add table
Add a link
Reference in a new issue