Correction bug dans establish_server (PR#438)

git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@3584 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
master
Xavier Leroy 2001-07-16 19:40:49 +00:00
parent 0b4de72b8d
commit 7d677e32cc
1 changed files with 6 additions and 3 deletions

View File

@ -844,7 +844,7 @@ let establish_server server_fun sockaddr =
socket domain SOCK_STREAM 0 in
setsockopt sock SO_REUSEADDR true;
bind sock sockaddr;
listen sock 3;
listen sock 5;
while true do
let (s, caller) = accept sock in
(* The "double fork" trick, the process which calls server_fun will not
@ -854,8 +854,11 @@ let establish_server server_fun sockaddr =
let inchan = in_channel_of_descr s in
let outchan = out_channel_of_descr s in
server_fun inchan outchan;
close_in inchan;
close_out outchan
close_out outchan;
(* The file descriptor was already closed by close_out.
close_in inchan;
*)
exit 0
| id -> close s; ignore(waitpid [] id) (* Reclaim the son *)
done