aboutsummaryrefslogtreecommitdiff
path: root/lib/spawned.ml
diff options
context:
space:
mode:
authorPierre-Marie Pédrot2014-04-07 17:22:58 +0200
committerPierre-Marie Pédrot2014-04-09 13:35:04 +0200
commitd481fb0ee62e1e09f2149a853da6f5d5498e47fb (patch)
treee44b2361e7440e107f25dcae3acd87468ed7960a /lib/spawned.ml
parent66f19ac2fcb3af564bd54077015597f97084b824 (diff)
Removing handshake from Spawn. It used marshalling, which is bad for
non-ML applications. Control channel can be also ignored.
Diffstat (limited to 'lib/spawned.ml')
-rw-r--r--lib/spawned.ml37
1 files changed, 18 insertions, 19 deletions
diff --git a/lib/spawned.ml b/lib/spawned.ml
index 9c304435b5..d025945690 100644
--- a/lib/spawned.ml
+++ b/lib/spawned.ml
@@ -31,7 +31,6 @@ let open_bin_connection h p =
let cin, cout = open_connection (ADDR_INET (inet_addr_of_string h,p)) in
set_binary_mode_in cin true;
set_binary_mode_out cout true;
- handshake cin cout;
cin, cout
let controller h p =
@@ -59,24 +58,24 @@ let channels = ref None
let init_channels () =
if !channels <> None then Errors.anomaly(Pp.str "init_channels called twice");
- match !main_channel, !control_channel with
- | None, None -> ()
- | None, Some _ | Some _, None ->
- Errors.anomaly (Pp.str "incomplete channels options")
- | _, Some AnonPipe ->
- Errors.anomaly (Pp.str "control channel cannot be a pipe")
- | Some (Socket(mh,mp)), Some (Socket(ch,cp)) ->
- channels := Some (open_bin_connection mh mp);
- controller ch cp
- | Some AnonPipe, Some (Socket (ch,cp)) ->
- let stdin = Unix.in_channel_of_descr (Unix.dup Unix.stdin) in
- let stdout = Unix.out_channel_of_descr (Unix.dup Unix.stdout) in
- Unix.dup2 Unix.stderr Unix.stdout;
- set_binary_mode_in stdin true;
- set_binary_mode_out stdout true;
- channels := Some (stdin, stdout);
- handshake stdin stdout;
- controller ch cp
+ let () = match !main_channel with
+ | None -> ()
+ | Some (Socket(mh,mp)) ->
+ channels := Some (open_bin_connection mh mp);
+ | Some AnonPipe ->
+ let stdin = Unix.in_channel_of_descr (Unix.dup Unix.stdin) in
+ let stdout = Unix.out_channel_of_descr (Unix.dup Unix.stdout) in
+ Unix.dup2 Unix.stderr Unix.stdout;
+ set_binary_mode_in stdin true;
+ set_binary_mode_out stdout true;
+ channels := Some (stdin, stdout);
+ in
+ match !control_channel with
+ | None -> ()
+ | Some (Socket (ch, cp)) ->
+ controller ch cp
+ | Some AnonPipe ->
+ Errors.anomaly (Pp.str "control channel cannot be a pipe")
let get_channels () =
match !channels with