From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@sympa.inria.fr Delivered-To: caml-list@sympa.inria.fr Received: from mail1-relais-roc.national.inria.fr (mail1-relais-roc.national.inria.fr [192.134.164.82]) by sympa.inria.fr (Postfix) with ESMTPS id D1C227F1C3 for ; Tue, 27 Nov 2012 14:03:12 +0100 (CET) Received-SPF: None (mail1-smtp-roc.national.inria.fr: no sender authenticity information available from domain of info@gerd-stolpmann.de) identity=pra; client-ip=212.227.17.9; receiver=mail1-smtp-roc.national.inria.fr; envelope-from="info@gerd-stolpmann.de"; x-sender="info@gerd-stolpmann.de"; x-conformance=sidf_compatible Received-SPF: None (mail1-smtp-roc.national.inria.fr: no sender authenticity information available from domain of info@gerd-stolpmann.de) identity=mailfrom; client-ip=212.227.17.9; receiver=mail1-smtp-roc.national.inria.fr; envelope-from="info@gerd-stolpmann.de"; x-sender="info@gerd-stolpmann.de"; x-conformance=sidf_compatible Received-SPF: Pass (mail1-smtp-roc.national.inria.fr: domain of postmaster@moutng.kundenserver.de designates 212.227.17.9 as permitted sender) identity=helo; client-ip=212.227.17.9; receiver=mail1-smtp-roc.national.inria.fr; envelope-from="info@gerd-stolpmann.de"; x-sender="postmaster@moutng.kundenserver.de"; x-conformance=sidf_compatible; x-record-type="v=spf1" X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AvIAAE25tFDU4xEJk2dsb2JhbABEwCckAQEBAQkJCwkUAySCJTo/KXQbBhMJiAgIsCCQSxSMH4RBA41hiTySGA X-IronPort-AV: E=Sophos;i="4.83,328,1352070000"; d="scan'208";a="183436720" Received: from moutng.kundenserver.de ([212.227.17.9]) by mail1-smtp-roc.national.inria.fr with ESMTP/TLS/RC4-SHA; 27 Nov 2012 14:03:12 +0100 Received: from office1.lan.sumadev.de (dslb-094-219-211-217.pools.arcor-ip.net [94.219.211.217]) by mrelayeu.kundenserver.de (node=mrbap3) with ESMTP (Nemesis) id 0MINbz-1TfFpA3fMl-003bv6; Tue, 27 Nov 2012 14:03:05 +0100 Received: from samsung (ip-5-146-55-186.unitymediagroup.de [5.146.55.186]) by office1.lan.sumadev.de (Postfix) with ESMTPSA id 74789C00CF; Tue, 27 Nov 2012 14:03:03 +0100 (CET) Date: Tue, 27 Nov 2012 14:03:03 +0100 From: Gerd Stolpmann To: Mike Lin Cc: ocamlnet-devel@lists.sourceforge.net, "caml-list@inria.fr" In-Reply-To: (from mlin@mlin.net on Tue Nov 27 03:54:16 2012) X-Mailer: Balsa 2.4.11 Message-Id: <1354021383.3169.2@samsung> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; DelSp=Yes; Format=Flowed Content-Disposition: inline Content-Transfer-Encoding: quoted-printable X-Provags-ID: V02:K0:8HhRlVVTm+adYI8GOCZ5mgtd8RnsTfP/fl/mQSI9xgf 9Xq1kKGYngeuJDsF+uwxbKK6u7KHhFFL6y9wgPSb2180WpkQF2 vgNfQBLmzQo4ycMcZkJj84jEIoYCAUlN2qTLO5eYvkCpUJhwLz IWn14AZ0PJzQqoaNICH3F8ag+sTzMDlEPaaYCf5yyykXWK4aOT fjNMwzaIN6DIGEJZOj1koB7MxXjmZuqlGWR945tdtU6D+4Ktz8 VnDC6Fl41i2LeveWl1hUvZqncQzGE6UzkyHvX5VhSjPI//erg1 M6AaM/JpYnTXSalEmPg3C/8c6n2t0LPSd/O6fSYJDKBYHbSerk hcph+rfjALhhCnNZhu9Y= Subject: [Caml-list] AW: Multithreaded https requests in ocamlnet netclient Hi Mike, I can confirm the problem, but I'm not able to track it down. First of all, I'm quite sure that you cannot share SSL contexts between=20= =20 threads. But even if I fix this, I get crashes - usually early during=20=20 SSL_connect. I'm wondering whether ocaml-ssl initializes openssl correctly for=20=20 multi-threading. In my version of openssl the prototype is int CRYPTO_THREADID_set_callback(void (*threadid_func)(CRYPTO_THREADID=20= =20 *)); but in ocaml-ssl the CRYPTO_THREADID pointer is ignored (it assumes=20=20 void here). So, maybe this is the reason. I currently don't have time=20=20 to follow this idea. If everything fails, there is a way to use Netclient in threaded=20=20 applications so that only one thread is doing the networking stuff, see=20= =20 this example: https://godirepo.camlcity.org/svn/lib-ocamlnet2/trunk/code/examples/netclie= nt/simple/http_mt.ml As Netclient is event-driven, the requests are processed in parallel=20=20 (with one exception, though: DNS lookups are synchronous, but this can=20= =20 be worked around, as the DNS lookup function is settable in Netclient). Gerd Am 27.11.2012 03:54:16 schrieb(en) Mike Lin: > Hello Gerd, all, >=20 > I'm trying to find the right incantations to make parallel https=20=20 > requests > from multiple threads using Http_client. (I know the library is=20=20 > capable of > multiple requests from one thread -- I have other strong reasons to=20=20 > use > multithreading.) >=20 > https://gist.github.com/4152047 >=20 > This program generally segfaults for me at some random point during=20=20 > the 10 > requests. Compiled as in the comment in line 2 (ubuntu quantal, > libocamlnet-ocaml-dev 3.5.1, ocaml 3.12.1). >=20 > Permutations attempted: >=20 > 1) Change https to http in google URL -- works as expected > 2) Serialize requests by uncommenting line 35 -- works as expected > 3) Move invocations of Ssl.init, Ssl.create_context, > HTTPS.https_transport_channel_type in and out of fresh_pipeline=20=20 > (which runs > in the worker threads) -- no help >=20 > Any suggestions? Thanks! >=20 > Mike Lin >=20 --=20 ------------------------------------------------------------ Gerd Stolpmann, Darmstadt, Germany gerd@gerd-stolpmann.de Creator of GODI and camlcity.org. Contact details: http://www.camlcity.org/contact.html Company homepage: http://www.gerd-stolpmann.de ------------------------------------------------------------=