Re: Http_client.Http_protocol (Unix.Unix_error (Unix.EINPROGRESS, "connect", "")).

Gerd Stolpmann <[email protected]> Tue, 03 Jan 2012 12:41:31 +0100
Newsgroups gmane.comp.lang.ocaml.lib.net.devel
Message-ID <1325590891.5036.224.camel@samsung>
I guess the double linking happened before the final linking step (and
probably with the best intentions). What you can do with bytecode (but
not with native code) is:

ocamlc -a -o newlib.cma unix.cma lib.cma

So, newlib.cma includes now unix.cma, and if unix.cma is added again by
the final linking step, you get it twice.

Here is how to create the problem step by step:

--- z.ml ---

let m ex =
  match ex with
    | Unix.Unix_error(_,_,_) ->
	print_endline "match"
    | _ ->
	print_endline "nomatch"

--- y.ml ---

let () =
  Z.m(Unix.Unix_error(Unix.ENOENT,"",""))

Now link as follows:

$ ocamlc -o z unix.cma z.ml unix.cma y.ml

And:

$ ./z
nomatch

ocamlopt is immune:

ocamlopt -o z unix.cmxa z.ml unix.cmxa y.ml
File "y.ml", line 1, characters 0-1:
Error: Files /opt/godi-3.12/lib/ocaml/std-lib/unix.cmxa
       and /opt/godi-3.12/lib/ocaml/std-lib/unix.cmxa
       both define a module named Unix

I've opened a bug report (http://caml.inria.fr/mantis/view.php?id=5461).

Gerd

Am Dienstag, den 03.01.2012, 11:39 +0100 schrieb Pierre-Alexandre Voye:
> Good shot, thank you !
> with ocamlobjinfo, i have : 
>     2a19929a535447ed0c8fc58ae3adc1a0    Unix
>     2a19929a535447ed0c8fc58ae3adc1a0    Unix
> 
> When i make the webserver with ocamlfind, ocamlc launchs :
>     
> + /Developer/usr/bin/clang -o 'cwbtop'
> '-L/opt/local/lib/ocaml/site-lib/pcre'
> '-L/opt/local/lib/ocaml/site-lib/netsys'
> '-L/opt/local/lib/ocaml/site-lib/netstring'
> '-L/opt/local/lib/ocaml/site-lib/netcgi2'
> '-L/opt/local/lib/ocaml/site-lib/equeue'
> '-L/opt/local/lib/ocaml/site-lib/netgssapi'
> '-L/opt/local/lib/ocaml/site-lib/rpc'
> '-L/opt/local/lib/ocaml/site-lib/netplex'
> '-L/opt/local/lib/ocaml/site-lib/nethttpd'
> '-L/opt/local/lib/ocaml/site-lib/nethttpd-for-netcgi2'
> '-L/opt/local/lib/ocaml/site-lib/netclient'
> '-L/opt/local/lib/ocaml/site-lib/easy-format'
> '-L/opt/local/lib/ocaml/site-lib/atd'
> '-L/opt/local/lib/ocaml/site-lib/biniou'
> '-L/opt/local/lib/ocaml/site-lib/yojson'
> '-L/opt/local/lib/ocaml/site-lib/atdgen'
> '-L/opt/local/lib/ocaml/site-lib/ssl'
> '-L/opt/local/lib/ocaml/site-lib/equeue-ssl'
> '-L/opt/local/lib/ocaml/site-lib/rpc-ssl' '-L/opt/local/lib/ocaml'
> -L/opt/local/lib
> '/var/folders/nh/pbvym9z90wj_9kt95s16p_3h0000gn/T/camlprim21027d.c'
> '-lequeue_ssl' 
> '-lunix' 
> '-lssl_stubs' '-lcrypto' '-lssl' '-lcamlstr' '-lnetaccel_c' '-lnetsys'
> '-lpthread' '-lbigarray' 
> '-lunix' 
> '-L/opt/local/lib' '-lpcre' '-lpcre_stubs' '-lcamlrun'
> -I'/opt/local/lib/ocaml' -lcurses -lpthread
> 
> In fact, it works well with ocamlopt as you said. It's realy a problem
> of double link
> 
> I searched a bit around this problem, but i don't find a way to fix
> it : the clang command line always call unix two times...
> (But i can test with a native version it's a beginning)
> 
> 2011/12/29 Gerd Stolpmann <[email protected]>
>         Hi,
>         
>         I cannot reproduce the problem (using my quite recent GODI
>         installation). That EINPROGRESS "breaks out" is quite strange,
>         because
>         the HTTP connection is made via Uq_engines.direct_connector,
>         and there
>         it is caught.
>         
>         A subtle problem I could imagine is that one of the libraries
>         includes
>         unix.cma erroneously (i.e. the Unix module is defined twice),
>         and
>         because of this there are two versions of Unix_error, and one
>         cannot
>         catch this exception anymore. You could check this by running
>         ocamlobjinfo on the cma files, and looking whether a "Unit
>         name" of Unix
>         occurs (should only be in unix.cma). (Btw: Do you see the
>         problem also
>         for ocamlopt-compiled programs? cmxa's cannot be partially
>         linked,
>         unlike cma's, so a linking problem is not possible.)
>         
>         My versions are:
>         
>         godi-atd-1.0.1godi1            Syntax for cross-language data
>         types
>         godi-atdgen-1.2.2              Code generator for biniou and
>         JSON serialization
>         godi-biniou-1.0.0godi1         Flexible binary data format
>         godi-easy-format-1.0.0godi1    Indentation made easy(ier)
>         godi-ocaml-3.12.1godi2         The core of the OCaml system
>         (compiler, runtime)
>         godi-ocaml-src-3.12.1godi1     OCaml sources (required for
>         GODI builds)
>         godi-ocaml-ssl-0.4.4godi2      The Secure Socket Layer
>         godi-ocamlnet-3.4.1            base library for network
>         protocols
>         godi-ocamlnet-crypto-3.4.1     crypto extension for ocamlnet
>         godi-ocamlnet-ssl-3.4.1        SSL extension for ocamlnet
>         godi-pcre-6.2.3                Perl compatible regular
>         expressions
>         godi-yojson-1.0.2godi1         JSON library succeeding to
>         json-wheel
>         
>         We can enable debugging. I get then:
>         
>         # Http_client.Debug.enable := true;;
>         - : unit = ()
>         # Http_client.Convenience.http_get "http://perdu.com";;
>         [Thu Dec 29 00:17:20 2011] [debug] [32146:0] Http_client: HTTP
>         connection: creating direct connection to perdu.com:80
>         [Thu Dec 29 00:17:20 2011] [debug] [32146:0] Http_client: FD 3
>         - HTTP direct connection to perdu.com:80: Connected!
>         [Thu Dec 29 00:17:20 2011] [debug] [32146:0] Http_client: HTTP
>         Connection: adding call 74
>         [Thu Dec 29 00:17:20 2011] [debug] [32146:0] Http_client: Call
>         74: initialize transmitter
>         [Thu Dec 29 00:17:20 2011] [debug] [32146:0] Http_client: FD 3
>         - Call 74 - HTTP request: GET / HTTP/1.1
>         [Thu Dec 29 00:17:20 2011] [debug] [32146:0] Http_client: FD 3
>         - HTTP connection: Got Call 74!
>         [Thu Dec 29 00:17:20 2011] [debug] [32146:0] Http_client: FD 3
>         - HTTP connection: pipelining=true persistency=false
>         close_connection=false->false
>         [Thu Dec 29 00:17:20 2011] [debug] [32146:0] Http_client: Call
>         74 - postprocessing
>         [Thu Dec 29 00:17:20 2011] [debug] [32146:0] Http_client: FD 3
>         - HTTP connection: Shutdown!
>         [Thu Dec 29 00:17:20 2011] [debug] [32146:0] Http_client: FD 3
>         - HTTP connection: Closing socket!
>         [Thu Dec 29 00:17:20 2011] [debug] [32146:0] Http_client: HTTP
>         connection: checking remaining pipeline requests
>         - : string =
>         "<html><head><title>Vous Etes
>         Perdu ?</title></head><body><h1>Perdu sur
>         l'Internet ?</h1><h2>Pas de panique, on va vous
>         aider</h2><strong><pre>    * <----- vous &ecirc;tes
>         ici</pre></strong></body></html>\n"
>         
>         
>         Gerd
>         
>         Am Freitag, den 23.12.2011, 16:11 +0100 schrieb
>         Pierre-Alexandre Voye:
>         > Hi everyone,
>         >
>         > I have just discovered a strange behavior of ocamlnet.
>         >
>         > As i understood, it seems like if you load certain library
>         together,
>         > the library is unable to make a simple http_get.
>         > I need to add these libs (particularly SSL), because i have
>         to write a
>         > POST multipart https function.
>         >
>         > Here an example with the toplevel which show the problem :
>         > (Sorry for the long long command)
>         >
>         > 1. It works :-)
>         >
>         > $ ocaml -I /opt/local/lib/ocaml/site-lib/pcre
>         > -I /opt/local/lib/ocaml/site-lib/netsys
>         > -I /opt/local/lib/ocaml/site-lib/netstring
>         > -I /opt/local/lib/ocaml/site-lib/netcgi2
>         > -I /opt/local/lib/ocaml/site-lib/equeue
>         >
>         -I /opt/local/lib/ocaml/site-lib/netclient /opt/local/lib/ocaml/site-lib/pcre/pcre.cma /opt/local/lib/ocaml/unix.cma /opt/local/lib/ocaml/bigarray.cma /opt/local/lib/ocaml/site-lib/netsys/netsys_oothr.cma /opt/local/lib/ocaml/site-lib/netsys/netsys.cma /opt/local/lib/ocaml/site-lib/netstring/netstring.cma /opt/local/lib/ocaml/site-lib/netstring/netaccel.cma /opt/local/lib/ocaml/site-lib/netstring/netaccel_link.cmo /opt/local/lib/ocaml/site-lib/netcgi2/netcgi.cma /opt/local/lib/ocaml/site-lib/equeue/equeue.cma /opt/local/lib/ocaml/site-lib/netgssapi/netgssapi.cma /opt/local/lib/ocaml/site-lib/rpc/rpc.cma /opt/local/lib/ocaml/site-lib/netplex/netplex.cma /opt/local/lib/ocaml/site-lib/nethttpd/nethttpd.cma /opt/local/lib/ocaml/site-lib/netclient/netclient.cma
>         >
>         >         Objective Caml version 3.12.1
>         >
>         > # Http_client.Convenience.http_get "http://perdu.com";;
>         > - : string =
>         > "<html><head><title>Vous Etes
>         Perdu ?</title></head><body><h1>Perdu
>         > sur l'Internet ?</h1><h2>Pas de panique, on va vous
>         > aider</h2><strong><pre>    * <----- vous &ecirc;tes
>         > ici</pre></strong></body></html>\n"
>         >
>         >
>         > 2. There's a problem !
>         >
>         > ocaml -I /opt/local/lib/ocaml/site-lib/pcre
>         > -I /opt/local/lib/ocaml/site-lib/netsys
>         > -I /opt/local/lib/ocaml/site-lib/netstring
>         > -I /opt/local/lib/ocaml/site-lib/netcgi2
>         > -I /opt/local/lib/ocaml/site-lib/equeue
>         > -I /opt/local/lib/ocaml/site-lib/netgssapi
>         > -I /opt/local/lib/ocaml/site-lib/rpc
>         > -I /opt/local/lib/ocaml/site-lib/netplex
>         > -I /opt/local/lib/ocaml/site-lib/nethttpd
>         > -I /opt/local/lib/ocaml/site-lib/nethttpd-for-netcgi2
>         > -I /opt/local/lib/ocaml/site-lib/netclient
>         > -I /opt/local/lib/ocaml/site-lib/easy-format
>         > -I /opt/local/lib/ocaml/site-lib/atd
>         > -I /opt/local/lib/ocaml/site-lib/biniou
>         > -I /opt/local/lib/ocaml/site-lib/yojson
>         > -I /opt/local/lib/ocaml/site-lib/atdgen
>         > -I /opt/local/lib/ocaml/site-lib/ssl
>         > -I /opt/local/lib/ocaml/site-lib/equeue-ssl
>         >
>         -I /opt/local/lib/ocaml/site-lib/rpc-ssl /opt/local/lib/ocaml/site-lib/pcre/pcre.cma /opt/local/lib/ocaml/unix.cma /opt/local/lib/ocaml/bigarray.cma /opt/local/lib/ocaml/site-lib/netsys/netsys_oothr.cma /opt/local/lib/ocaml/site-lib/netsys/netsys.cma /opt/local/lib/ocaml/site-lib/netstring/netstring.cma /opt/local/lib/ocaml/site-lib/netstring/netaccel.cma /opt/local/lib/ocaml/site-lib/netstring/netaccel_link.cmo /opt/local/lib/ocaml/site-lib/netcgi2/netcgi.cma /opt/local/lib/ocaml/site-lib/equeue/equeue.cma /opt/local/lib/ocaml/site-lib/netgssapi/netgssapi.cma /opt/local/lib/ocaml/site-lib/rpc/rpc.cma /opt/local/lib/ocaml/site-lib/netplex/netplex.cma /opt/local/lib/ocaml/site-lib/nethttpd/nethttpd.cma /opt/local/lib/ocaml/site-lib/netclient/netclient.cma /opt/local/lib/ocaml/str.
 cma /opt/local/lib/ocaml/site-lib/easy-format/easy_format.cmo /opt/local/lib/ocaml/site-lib/atd/atd.cma /opt/local/lib/ocaml/site-lib/biniou/biniou.cma /opt/local/lib/ocaml/site-lib/yojson/yojson.cmo /opt/local/lib/ocaml/site-lib/atdgen/atdgen.cma /opt/local/lib/ocaml/site-lib/ssl/ssl.cma /opt/local/lib/ocaml/site-lib/equeue-ssl/equeue_ssl.cma /opt/local/lib/ocaml/site-lib/rpc-ssl/rpc_ssl.cma
>         >
>         > Objective Caml version 3.12.1
>         >
>         > # Http_client.Convenience.http_get "http://perdu.com";;
>         > Exception:
>         > Http_client.Http_protocol (Unix.Unix_error
>         (Unix.EINPROGRESS,
>         > "connect", "")).
>         >
>         >
>         > So every http_call doesn't work, and of course https  with
>         post verb.
>         >
>         > is anayone have an idea ?
>         >
>         >
>         >
>         > Merry Christmas to all !
>         >
>         >
>         > Pierre-Alexandre
>         > --
>         > ---------------------
>         > https://twitter.com/#!/ontologiae/
>         > http://linuxfr.org/users/montaigne
>         >
>         
>         >
>         ------------------------------------------------------------------------------
>         > Write once. Port to many.
>         > Get the SDK and tools to simplify cross-platform app
>         development. Create
>         > new or port existing apps to sell to consumers worldwide.
>         Explore the
>         > Intel AppUpSM program developer opportunity.
>         appdeveloper.intel.com/join
>         > http://p.sf.net/sfu/intel-appdev
>         > _______________________________________________
>         Ocamlnet-devel mailing list
>         [email protected]
>         https://lists.sourceforge.net/lists/listinfo/ocamlnet-devel
>         
>         
> 
> 
> 
> -- 
> ---------------------
> https://twitter.com/#!/ontologiae/
> http://linuxfr.org/users/montaigne
> 
> ------------------------------------------------------------------------------
> Write once. Port to many.
> Get the SDK and tools to simplify cross-platform app development. Create 
> new or port existing apps to sell to consumers worldwide. Explore the 
> Intel AppUpSM program developer opportunity. appdeveloper.intel.com/join
> http://p.sf.net/sfu/intel-appdev
> _______________________________________________ Ocamlnet-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/ocamlnet-devel



------------------------------------------------------------------------------
Write once. Port to many.
Get the SDK and tools to simplify cross-platform app development. Create 
new or port existing apps to sell to consumers worldwide. Explore the 
Intel AppUpSM program developer opportunity. appdeveloper.intel.com/join
http://p.sf.net/sfu/intel-appdev