Skip to content

Commit 5426777

Browse files
committed
Delete socket file before starting server
If Dream is started as a Unix socket server, then try to delete the socket file before binding to it. If it doesn't exist, just carry on. Fix #398
1 parent af3c9bf commit 5426777

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/http/http.ml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -494,6 +494,11 @@ let serve_with_details
494494
let%lwt listen_address =
495495
match network with
496496
| `Unix path ->
497+
(* Optimistically delete the socket file, if any. *)
498+
let%lwt () =
499+
try%lwt Lwt_unix.unlink path
500+
with Unix.Unix_error (ENOENT, _, _) -> Lwt.return_unit
501+
in
497502
Lwt.return (Lwt_unix.ADDR_UNIX path)
498503
| `Inet port ->
499504
let%lwt addresses =

0 commit comments

Comments
 (0)