12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182(*
* Copyright (c) 2016 Docker Inc
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
*)openLwtexceptionNot_availablelet()=Callback.register_exception"named-pipe.lwt:not-available"Not_availablemoduleServer=structtypet=Unix.file_descrletto_fdx=Lwt_unix.of_unix_file_descr~blocking:truexexternalcreate':string->t="stub_named_pipe_create"letcreatepath=ifSys.os_type<>"Win32"thenraiseNot_available;create'pathexternalconnect_job:t->unitLwt_unix.job="named_pipe_lwt_connect_job"letconnectt=ifSys.os_type<>"Win32"thenraiseNot_available;Lwt_unix.run_job(connect_jobt)externalflush_job:t->unitLwt_unix.job="named_pipe_lwt_flush_job"letflusht=ifSys.os_type<>"Win32"thenraiseNot_available;Lwt_unix.run_job(flush_jobt)externaldisconnect':t->unit="stub_named_pipe_disconnect"letdisconnectt=ifSys.os_type<>"Win32"thenraiseNot_available;disconnect'texternaldestroy':t->unit="stub_named_pipe_destroy"letdestroyt=ifSys.os_type<>"Win32"thenraiseNot_available;destroy'tendmoduleClient=structtypet=Unix.file_descrletto_fdx=Lwt_unix.of_unix_file_descr~blocking:truexexternalwait_job:string->int->unitLwt_unix.job="named_pipe_lwt_wait_job"letwaitpathms=ifSys.os_type<>"Win32"thenraiseNot_available;Lwt_unix.run_job(wait_jobpathms)letrecopenpipepath=ifSys.os_type<>"Win32"thenraiseNot_available;tryletfd=Unix.openfilepath[Unix.O_RDWR]0inLwt.returnfdwithUnix.Unix_error(Unix.EUNKNOWNERR-231,_,_)->(* ERROR_PIPE_BUSY *)waitpath1000>>=fun()->openpipepath|e->raiseeend