* Ocamlnet and EINPROGRESS
@ 2008-04-03 1:06 Yitzhak Mandelbaum
2008-04-03 1:52 ` [Caml-list] " Eric Cooper
0 siblings, 1 reply; 7+ messages in thread
From: Yitzhak Mandelbaum @ 2008-04-03 1:06 UTC (permalink / raw)
To: caml List
[-- Attachment #1: Type: text/plain, Size: 501 bytes --]
Hi,
I'm using the Http_client.Convenience module to get web pages.
Unfortunately, if I link the Unix module into my program, then
suddenly I get the Unix_error exception with code EINPROGRESS (38).
I noticed this issue raised on the list last August, but it does not
seem to have been resolved. Does anyone know how to solve this?
Thanks,
Yitzhak Mandelbaum
--------------------------------------------------
Yitzhak Mandelbaum
AT&T Labs - Research
http://www.research.att.com/~yitzhak
[-- Attachment #2: Type: text/html, Size: 2724 bytes --]
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Caml-list] Ocamlnet and EINPROGRESS
2008-04-03 1:06 Ocamlnet and EINPROGRESS Yitzhak Mandelbaum
@ 2008-04-03 1:52 ` Eric Cooper
2008-04-03 2:08 ` Yitzhak Mandelbaum
0 siblings, 1 reply; 7+ messages in thread
From: Eric Cooper @ 2008-04-03 1:52 UTC (permalink / raw)
To: caml-list
On Wed, Apr 02, 2008 at 09:06:56PM -0400, Yitzhak Mandelbaum wrote:
> I'm using the Http_client.Convenience module to get web pages.
> Unfortunately, if I link the Unix module into my program, then suddenly
> I get the Unix_error exception with code EINPROGRESS (38).
I don't see this with a trivial program that just does http_get:
open Http_client.Convenience
let () = print_string (http_get Sys.argv.(1))
The EINPROGRESS is from a connect() call on a socket that's been set
non-blocking. Running the above program under strace shows that this
occurs, but it's handled within http_get.
Can you post a minimal example that shows the exception escaping?
--
Eric Cooper e c c @ c m u . e d u
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Caml-list] Ocamlnet and EINPROGRESS
2008-04-03 1:52 ` [Caml-list] " Eric Cooper
@ 2008-04-03 2:08 ` Yitzhak Mandelbaum
2008-04-03 2:30 ` Eric Cooper
0 siblings, 1 reply; 7+ messages in thread
From: Yitzhak Mandelbaum @ 2008-04-03 2:08 UTC (permalink / raw)
To: Eric Cooper; +Cc: caml-list
[-- Attachment #1: Type: text/plain, Size: 1445 bytes --]
Sure, here's one:
let mystring = Http_client.Convenience.http_get "http://www.cnn.com"
But, whether or not it raises the exception depends what I link it
with, which is the essential problem.
Yitzhak
On Apr 2, 2008, at 9:52 PM, Eric Cooper wrote:
> On Wed, Apr 02, 2008 at 09:06:56PM -0400, Yitzhak Mandelbaum wrote:
>> I'm using the Http_client.Convenience module to get web pages.
>> Unfortunately, if I link the Unix module into my program, then
>> suddenly
>> I get the Unix_error exception with code EINPROGRESS (38).
>
> I don't see this with a trivial program that just does http_get:
> open Http_client.Convenience
> let () = print_string (http_get Sys.argv.(1))
>
> The EINPROGRESS is from a connect() call on a socket that's been set
> non-blocking. Running the above program under strace shows that this
> occurs, but it's handled within http_get.
>
> Can you post a minimal example that shows the exception escaping?
>
> --
> Eric Cooper e c c @ c m u . e d u
>
> _______________________________________________
> Caml-list mailing list. Subscription management:
> http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list
> Archives: http://caml.inria.fr
> Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
> Bug reports: http://caml.inria.fr/bin/caml-bugs
--------------------------------------------------
Yitzhak Mandelbaum
AT&T Labs - Research
http://www.research.att.com/~yitzhak
[-- Attachment #2: Type: text/html, Size: 6603 bytes --]
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Caml-list] Ocamlnet and EINPROGRESS
2008-04-03 2:08 ` Yitzhak Mandelbaum
@ 2008-04-03 2:30 ` Eric Cooper
2008-04-03 2:43 ` Yitzhak Mandelbaum
0 siblings, 1 reply; 7+ messages in thread
From: Eric Cooper @ 2008-04-03 2:30 UTC (permalink / raw)
To: caml-list
On Wed, Apr 02, 2008 at 10:08:55PM -0400, Yitzhak Mandelbaum wrote:
> Sure, here's one:
>
> let mystring = Http_client.Convenience.http_get "http://www.cnn.com"
>
> But, whether or not it raises the exception depends what I link it
> with, which is the essential problem.
On my (Debian) system, I can't build that program without linking in
the Unix module, since it's referenced by almost all of the ocamlnet
modules. So I don't understand the problem you're seeing.
--
Eric Cooper e c c @ c m u . e d u
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Caml-list] Ocamlnet and EINPROGRESS
2008-04-03 2:30 ` Eric Cooper
@ 2008-04-03 2:43 ` Yitzhak Mandelbaum
2008-04-03 7:12 ` Stéphane Glondu
0 siblings, 1 reply; 7+ messages in thread
From: Yitzhak Mandelbaum @ 2008-04-03 2:43 UTC (permalink / raw)
To: Eric Cooper; +Cc: caml-list
[-- Attachment #1: Type: text/plain, Size: 2242 bytes --]
Its a little more complicated than that. The problem arises when
linking with 1) a library that links with Unix and 2) a file that
depends on Unix. I've found a minimal example that fails on my system
(OS X). It involves 4 files: Makefile, mintime.ml, unixprog.ml,
minprog.ml (names chosen arbitrarily):
########################
Makefile:
########################
all: minprog
timelib.cma: mintime.ml
ocamlfind ocamlc -package unix -linkpkg \
-o $@ -a mintime.ml
minprog: timelib.cma unixprog.ml
ocamlfind ocamlc $(INCLUDES) -thread -o $@ \
-package netclient -linkpkg $^ minprog.ml
########################
mintime.ml:
#######################
let now () = Unix.time ()
########################
unixprog.ml:
#######################
let foo x =
let in_channel, out_channel = Unix.open_process "cat" in
let read_fd = Unix.descr_of_in_channel in_channel in
let write_fd = Unix.descr_of_out_channel out_channel in
()
########################
minprog.ml:
#######################
let mystring = Http_client.Convenience.http_get "http://www.cnn.com"
Then,
make minprog
./minprog
results in
Fatal error: exception Unix.Unix_error(38, "connect", "")
Yitzhak
On Apr 2, 2008, at 10:30 PM, Eric Cooper wrote:
> On Wed, Apr 02, 2008 at 10:08:55PM -0400, Yitzhak Mandelbaum wrote:
>> Sure, here's one:
>>
>> let mystring = Http_client.Convenience.http_get "http://
>> www.cnn.com"
>>
>> But, whether or not it raises the exception depends what I link it
>> with, which is the essential problem.
>
> On my (Debian) system, I can't build that program without linking in
> the Unix module, since it's referenced by almost all of the ocamlnet
> modules. So I don't understand the problem you're seeing.
>
> --
> Eric Cooper e c c @ c m u . e d u
>
> _______________________________________________
> Caml-list mailing list. Subscription management:
> http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list
> Archives: http://caml.inria.fr
> Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
> Bug reports: http://caml.inria.fr/bin/caml-bugs
--------------------------------------------------
Yitzhak Mandelbaum
AT&T Labs - Research
http://www.research.att.com/~yitzhak
[-- Attachment #2: Type: text/html, Size: 8031 bytes --]
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Caml-list] Ocamlnet and EINPROGRESS
2008-04-03 2:43 ` Yitzhak Mandelbaum
@ 2008-04-03 7:12 ` Stéphane Glondu
2008-04-03 13:33 ` Dario Teixeira
0 siblings, 1 reply; 7+ messages in thread
From: Stéphane Glondu @ 2008-04-03 7:12 UTC (permalink / raw)
To: Yitzhak Mandelbaum; +Cc: Eric Cooper, caml-list
Yitzhak Mandelbaum a écrit :
> timelib.cma: mintime.ml ocamlfind ocamlc -package unix -linkpkg \ -o $@
> -a mintime.ml
> minprog: timelib.cma unixprog.ml ocamlfind ocamlc $(INCLUDES) -thread
> -o $@ \ -package netclient -linkpkg $^ minprog.ml
With these rules, you link the Unix module twice. Try without -linkpkg
in the first rule. More generally, avoid using -linkpkg when making .cma
unless you know what you are doing (use it only in the final stage of
linking).
Cheers,
--
Stéphane
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Caml-list] Ocamlnet and EINPROGRESS
2008-04-03 7:12 ` Stéphane Glondu
@ 2008-04-03 13:33 ` Dario Teixeira
0 siblings, 0 replies; 7+ messages in thread
From: Dario Teixeira @ 2008-04-03 13:33 UTC (permalink / raw)
To: caml-list
> With these rules, you link the Unix module twice. Try without -linkpkg
> in the first rule. More generally, avoid using -linkpkg when making .cma
> unless you know what you are doing (use it only in the final stage of
> linking).
Indeed. And on that note I would like to report a similar problem
with the "ocamlfind+ocamlbuild" plugin that was discussed on this
list some weeks ago, and available on the Ocamlbuild wiki:
http://brion.inria.fr/gallium/index.php/Using_ocamlfind_with_ocamlbuild
This is the offending code:
(* When one link an OCaml library/binary/package, one should use -linkpkg.
*)
flag ["ocaml"; "link"] & A"-linkpkg";
As Stéphane mentioned, -linkpkg should normally not be used on libraries.
(I have personally run into problems because of this). The solution I
am using is to apply -linkpkg only when linking programmes:
(* When linking Ocaml programmes (and programmes only!), we use -linkpkg.
*)
flag ["ocaml"; "link"; "program"] & A"-linkpkg";
Regards,
Dario Teixeira
___________________________________________________________
Yahoo! For Good helps you make a difference
http://uk.promotions.yahoo.com/forgood/
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2008-04-03 13:33 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-04-03 1:06 Ocamlnet and EINPROGRESS Yitzhak Mandelbaum
2008-04-03 1:52 ` [Caml-list] " Eric Cooper
2008-04-03 2:08 ` Yitzhak Mandelbaum
2008-04-03 2:30 ` Eric Cooper
2008-04-03 2:43 ` Yitzhak Mandelbaum
2008-04-03 7:12 ` Stéphane Glondu
2008-04-03 13:33 ` Dario Teixeira
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox