caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: pierrchp@free.fr
To: caml-list@inria.fr, ocsigen@sympa.mancoosi.univ-paris-diderot.fr
Subject: [Caml-list] Ocamlnet, netclient and lwt_preemptive causing ocsigen segfault
Date: Sat, 10 Sep 2011 20:58:05 +0200	[thread overview]
Message-ID: <1315681085.4e6bb33d6df0e@imp.free.fr> (raw)


 Hello,

I have a web application written using lwt and ocsigen that needs to get data
using https.

In order to do that, I use the Http_client.Convenience module from Ocamlnet, and
use Lwt.detach to perform the call (there probably is a smater way to do this, I
am open to any suggestion). The http call is performed and the data is
displayed, but then the server crashed, apparently because of a segfault.

here is the code for a test eliom module that reproduce the problem, compiled
using

ocamlfind ocamlc -c -thread -package
equeue-ssl,netclient,lwt,lwt.preemptive,ocsigen test_server.ml

Cheers


-Pierre


(*************************************)

open Lwt
open XHTML.M
open Eliom_services
open Eliom_parameters
open Eliom_sessions
open Eliom_predefmod.Xhtml;;




(* initialising Http_client.Convenience to use https *)
  Ssl.init();

   Http_client.Convenience.configure_pipeline
      (fun p ->
         let ctx = Ssl.create_context Ssl.TLSv1 Ssl.Client_context in
             let tct = Https_client.https_transport_channel_type ctx in
                  p # configure_transport Http_client.https_cb_id tct
      )
;;



module H =  Http_client.Convenience


let test_service = new_service ~path:[""]
                               ~get_params:unit
  ()
;;


let test_handler = fun sp () () ->
(* thread that request data from a url *)
Lwt_preemptive.detach (function () -> H.http_get "https://ocsigen.org") () >>=
function s ->
(*page that display the data*)
 return (
html (head (title (pcdata "test")) [])
     (body [
          h1 [pcdata "the data are:"];
          p [ pcdata s]
           ]
     )
)
;;
register test_service test_handler;;

             reply	other threads:[~2011-09-10 18:58 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-09-10 18:58 pierrchp [this message]
2011-09-11  8:27 ` Gerd Stolpmann
2011-09-11 17:04 ` [Caml-list] Re: [Ocsigen] " Vincent Balat

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1315681085.4e6bb33d6df0e@imp.free.fr \
    --to=pierrchp@free.fr \
    --cc=caml-list@inria.fr \
    --cc=ocsigen@sympa.mancoosi.univ-paris-diderot.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).