From a0736ce4e1af0a9562f8773dc85c7c9f32f02b76 Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Mon, 6 Mar 2017 17:32:42 +0100 Subject: [PATCH 1/2] Fixed OCaml Address in use --- ocaml/TaskServer.ml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/ocaml/TaskServer.ml b/ocaml/TaskServer.ml index 6bfdc50e..23e887e6 100644 --- a/ocaml/TaskServer.ml +++ b/ocaml/TaskServer.ml @@ -62,7 +62,11 @@ let bind_socket ~socket_type ~socket ~port = | Unix.Unix_error _ -> (Time.pause @@ Time.Span.of_float 1. ; loop (i-1) ) | other_exception -> raise other_exception in loop 60; - ZMQ.Socket.bind socket @@ Printf.sprintf "ipc:///tmp/qp_run:%d" port + let filename = + Printf.sprintf "/tmp/qp_run:%d" port + in + Sys.remove filename; + ZMQ.Socket.bind socket ("ipc://"^filename) let hostname = lazy ( From d01ed36a2788d2d5e9f82884e7d91425dd27b4ed Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Mon, 6 Mar 2017 18:46:04 +0100 Subject: [PATCH 2/2] Fixed OCaml Address in use --- ocaml/TaskServer.ml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/ocaml/TaskServer.ml b/ocaml/TaskServer.ml index 23e887e6..a1625719 100644 --- a/ocaml/TaskServer.ml +++ b/ocaml/TaskServer.ml @@ -65,7 +65,11 @@ let bind_socket ~socket_type ~socket ~port = let filename = Printf.sprintf "/tmp/qp_run:%d" port in - Sys.remove filename; + begin + match Sys.file_exists filename with + | `Yes -> Sys.remove filename + | _ -> () + end; ZMQ.Socket.bind socket ("ipc://"^filename)