From a10be3a13dcc22283717c86e660a95a9f113875d Mon Sep 17 00:00:00 2001 From: Stefano Zacchiroli Date: Mon, 3 Jul 2006 16:32:26 +0000 Subject: [PATCH] when auto_close is set, use flush + shutdown instead of close_out, work around an ocaml 3.09.2 bug --- DEVEL/ocaml-http/debian/rules | 6 +++++- DEVEL/ocaml-http/http_daemon.ml | 10 +++++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/DEVEL/ocaml-http/debian/rules b/DEVEL/ocaml-http/debian/rules index bde072744..b8493ead0 100755 --- a/DEVEL/ocaml-http/debian/rules +++ b/DEVEL/ocaml-http/debian/rules @@ -6,12 +6,16 @@ PKGNAME = libhttp-ocaml-dev OCAMLABI := $(shell ocamlc -version) OCAMLLIBDIR := $(shell ocamlc -where) -OFILES := $(patsubst %.in,%,$(shell ls debian/*.in)) +OFILES_ALL := $(patsubst %.in,%,$(shell ls debian/*.in)) +OFILES := $(filter-out debian/rules, $(OFILES_ALL)) HAVE_OCAMLOPT := $(shell test -x /usr/bin/ocamlopt && echo "yes") DEB_DH_GENCONTROL_ARGS = -- -VF:OCamlABI="$(OCAMLABI)" DEB_MAKE_INSTALL_TARGET = install DESTDIR=$(CURDIR)/debian/$(PKGNAME)$(OCAMLLIBDIR) ocamlinit: + for f in $(OFILES_ALL); do sed -e 's/@OCamlABI@/$(OCAMLABI)/g' $$f.in > $$f; done + +makebuilddir/$(PKGNAME):: for f in $(OFILES); do sed -e 's/@OCamlABI@/$(OCAMLABI)/g' $$f.in > $$f; done ifeq ($(HAVE_OCAMLOPT),yes) diff --git a/DEVEL/ocaml-http/http_daemon.ml b/DEVEL/ocaml-http/http_daemon.ml index 1b922ea16..992f3b99a 100644 --- a/DEVEL/ocaml-http/http_daemon.ml +++ b/DEVEL/ocaml-http/http_daemon.ml @@ -303,7 +303,15 @@ let invoke_callback req spec outchan = let callback req outchan = if spec.auto_close then Http_misc.finally - (fun () -> try close_out outchan with Sys_error _ -> ()) + (fun () -> + (* XXX the pair flush + shutdown is a temporary solution since double + * close on a socket make ocaml 3.09.2 segfault (see + * http://caml.inria.fr/mantis/view.php?id=4059). The right thing to + * do is probably invoke try_close outchan here *) + flush outchan; + try + Unix.shutdown (Unix.descr_of_out_channel outchan) Unix.SHUTDOWN_ALL + with Unix.Unix_error(_, "shutdown", "") -> ()) (fun () -> spec.callback req outchan) () else spec.callback req outchan in -- 2.39.2