http_types.cmi http_response.cmi
http_response.cmx: http_common.cmx http_daemon.cmx http_misc.cmx \
http_types.cmx http_response.cmi
-http_tcp_server.cmo: http_tcp_server.cmi
-http_tcp_server.cmx: http_tcp_server.cmi
+http_tcp_server.cmo: http_threaded_tcp_server.cmi http_tcp_server.cmi
+http_tcp_server.cmx: http_threaded_tcp_server.cmi http_tcp_server.cmi
http_types.cmo: http_types.cmi
http_types.cmx: http_types.cmi
http_common.cmi: http_types.cmi
description = "OCaml HTTP daemon library"
version = "@DISTVERSION@"
requires = "unix,pcre,netstring"
+requires(mt) = "unix,pcre,netstring,threads"
archive(byte) = "http.cma"
archive(native) = "http.cmxa"
+archive(mt,byte) = "http_mt.cma"
+archive(mt,native) = "http_mt.cmxa"
include Makefile.defs
MODULES = http_common http_misc http_types http_request http_parser http_tcp_server http_daemon http_response
+THREADED_SRV = http_threaded_tcp_server
+MODULES_MT = $(patsubst http_tcp_server, mt/$(THREADED_SRV) http_tcp_server, $(MODULES))
+MODULES_NON_MT = $(patsubst http_tcp_server, non_mt/$(THREADED_SRV) http_tcp_server, $(MODULES))
PUBLIC_MODULES = http_common http_types http_request http_daemon http_response
DESTDIR = $(shell $(OCAMLFIND) printconf stdlib)
-all: http.cma
-opt: http.cmxa
+all: all_non_mt all_mt
+opt: opt_non_mt opt_mt
+all_non_mt: http.cma
+opt_non_mt: http.cmxa
+all_mt: http_mt.cma
+opt_mt: http_mt.cmxa
world: all opt
doc: *.mli
$(OCAMLDOC) -html -d doc/html *.mli
%.cmx: %.ml %.cmi
$(OCAMLOPT) -c $<
-http.cma: $(patsubst %,%.cmo,$(MODULES))
+non_mt/$(THREADED_SRV).cmo: non_mt/$(THREADED_SRV).ml $(THREADED_SRV).cmi
+ cp $(THREADED_SRV).{cmi,mli} non_mt/
+ $(OCAMLC) -c $<
+non_mt/$(THREADED_SRV).cmx: non_mt/$(THREADED_SRV).ml $(THREADED_SRV).cmi
+ cp $(THREADED_SRV).{cmi,mli} non_mt/
+ $(OCAMLOPT) -c $<
+
+mt/$(THREADED_SRV).cmo: mt/$(THREADED_SRV).ml $(THREADED_SRV).cmi
+ cp $(THREADED_SRV).{cmi,mli} mt/
+ $(OCAMLC) $(THREADS_FLAGS) -c $<
+mt/$(THREADED_SRV).cmx: mt/$(THREADED_SRV).ml $(THREADED_SRV).cmi
+ cp $(THREADED_SRV).{cmi,mli} mt/
+ $(OCAMLOPT) $(THREADS_FLAGS) -c $<
+
+http.cma: $(patsubst %,%.cmo,$(MODULES_NON_MT))
+ $(OCAMLC) -a -o $@ $^
+http.cmxa: $(patsubst %,%.cmx,$(MODULES_NON_MT))
+ $(OCAMLOPT) -a -o $@ $^
+http_mt.cma: $(patsubst %,%.cmo,$(MODULES_MT))
$(OCAMLC) -a -o $@ $^
-http.cmxa: $(patsubst %,%.cmx,$(MODULES))
+http_mt.cmxa: $(patsubst %,%.cmx,$(MODULES_MT))
$(OCAMLOPT) -a -o $@ $^
meta: META
clean:
$(MAKE) -C examples/ clean
- rm -f *.cm[ioax] *.cmxa *.[ao] test{,.opt}
+ for d in . mt non_mt; do \
+ rm -f $$d/*.cm[ioax] $$d/*.cmxa $$d/*.[ao] $$d/test{,.opt}; \
+ done
+ rm -f {mt,non_mt}/$(THREADED_SRV).mli
docclean:
rm -f doc/html/*.html doc/html/*.css
distclean: clean docclean
PKGNAME = http
DISTVERSION = $(shell dpkg-parsechangelog | egrep '^Version: ' | sed 's/^Version: //')
-DEBUG_OPTS =
-REQUIRES = unix pcre netstring threads
-COMMON_OPTS = $(DEBUG_OPTS) -pp camlp4o -package "$(REQUIRES)"
+DEBUG_FLAGS =
+REQUIRES = unix pcre netstring
+COMMON_FLAGS = $(DEBUG_FLAGS) -pp camlp4o -package "$(REQUIRES)"
+THREADS_FLAGS = -package threads -thread
OCAMLFIND = ocamlfind
-OCAMLC = $(OCAMLFIND) ocamlc $(COMMON_OPTS) -thread
-OCAMLOPT = $(OCAMLFIND) ocamlopt $(COMMON_OPTS) -thread
-OCAMLDEP = $(OCAMLFIND) ocamldep $(COMMON_OPTS)
+OCAMLC = $(OCAMLFIND) ocamlc $(COMMON_FLAGS)
+OCAMLOPT = $(OCAMLFIND) ocamlopt $(COMMON_FLAGS)
+OCAMLDEP = $(OCAMLFIND) ocamldep $(COMMON_FLAGS)
OCAMLDOC = ocamldoc
DISTNAME = ocaml-http
ocaml-http (0.0.6) unstable; urgency=low
+ * Now ship two versions of the library: multithreaded and
+ non-multithreaded
* Added support for multiple binding of the same parameter in request
objects (new method: 'paramAll')
* Added support for 'empty' bindings in query arguments (e.g.
include ../Makefile.defs
-OBJS = ../http.cma
-OBJS_OPT = ../http.cmxa
-EXAMPLES_OPTS = -I .. -linkpkg
+OBJS_NON_MT = ../http.cma
+OBJS_NON_MT_OPT = ../http.cmxa
+OBJS_MT = ../http_mt.cma
+OBJS_MT_OPT = ../http_mt.cmxa
+EXAMPLES_FLAGS = -I .. -linkpkg
EXAMPLES = \
- always_ok_daemon webfsd obj_foo dump_args timeout dont_fork threads chdir
+ always_ok_daemon webfsd obj_foo dump_args timeout dont_fork threads chdir threads_foo
all: $(EXAMPLES)
opt: $(patsubst %,%.opt,$(EXAMPLES))
%: %.ml $(OBJS)
- $(OCAMLC) $(EXAMPLES_OPTS) $(OBJS) -o $@ $<
+ $(OCAMLC) $(EXAMPLES_FLAGS) $(OBJS_NON_MT) -o $@ $<
%.opt: %.ml $(OBJS_OPT)
- $(OCAMLOPT) $(EXAMPLES_OPTS) $(OBJS_OPT) -o $@ $<
+ $(OCAMLOPT) $(EXAMPLES_FLAGS) $(OBJS_NON_MT_OPT) -o $@ $<
+
+threads: threads.ml
+ $(OCAMLC) $(EXAMPLES_FLAGS) $(OBJS_MT) $(THREADS_FLAGS) -o $@ $<
+threads.opt: threads.ml
+ $(OCAMLOPT) $(EXAMPLES_FLAGS) $(OBJS_MT_OPT) $(THREADS_FLAGS) -o $@ $<
+
+threads_foo: threads_foo.ml
+ $(OCAMLC) $(EXAMPLES_FLAGS) $(OBJS_MT) $(THREADS_FLAGS) -package netclient -o $@ $<
+threads_foo.opt: threads_foo.ml
+ $(OCAMLOPT) $(EXAMPLES_FLAGS) $(OBJS_MT_OPT) $(THREADS_FLAGS) -package netclient -o $@ $<
distclean: clean
clean:
--- /dev/null
+val serve : ('a -> 'b) -> 'a -> unit
--- /dev/null
+let serve callback arg = ignore (Thread.create callback arg)
--- /dev/null
+let serve _ _ =
+ failwith
+ ("Threaded server not supported by the non threaded version " ^
+ "of ocaml-http, please link against http_mt.cm{,x}a")