MacOS X support patches
Anil Madhavapeddy <[email protected]> Wed, 4 Feb 2009 16:55:54 +0000
| Newsgroups | gmane.comp.lang.ocaml.lib.net.devel |
|---|---|
| Message-ID | <[email protected]> |
It appears that getpeername(3) on MacOS X Leopard can return EINVAL under some conditions instead of an ENOTCONN. This isn't caught by OCamlnet and so it immediately goes into a spinloop. The following patches fix it for me, and shouldn't have an ill effect on other platforms. I've only tested it with Netplex/Nethttpd/Netcgi. -anil ------------------------------------------------------------------------------ Create and Deploy Rich Internet Apps outside the browser with Adobe(R)AIR(TM) software. With Adobe AIR, Ajax developers can use existing skills and code to build responsive, highly engaging applications that combine the power of local resources and data with the reach of the web. Download the Adobe AIR SDK and Ajax docs to start building applications today-http://p.sf.net/sfu/adobe-com _______________________________________________ Ocamlnet-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/ocamlnet-devel
patch-http_client.ml.diff
(application/octet-stream, 428 B)
--- src/netclient/http_client.ml.orig 2009-02-03 16:19:25.000000000 +0000 +++ src/netclient/http_client.ml 2009-02-03 16:19:50.000000000 +0000 @@ -1567,7 +1567,7 @@ if not (List.mem fd fd_list) then Hashtbl.replace rev_inactive_conns peer (fd :: fd_list) with - | Unix.Unix_error(Unix.ENOTCONN,_,_) -> + | Unix.Unix_error((Unix.ENOTCONN|Unix.EINVAL),_,_) -> self # forget_connection fd )
patch-rpc_transport.ml.diff
(application/octet-stream, 1 KB)
--- src/rpc/rpc_transport.ml.orig 2009-02-03 16:13:34.000000000 +0000
+++ src/rpc/rpc_transport.ml 2009-02-03 16:16:50.000000000 +0000
@@ -236,7 +236,7 @@
with
| Unix.Unix_error((Unix.EAFNOSUPPORT|Unix.EOPNOTSUPP),_,_) ->
Some `Implied
- | Unix.Unix_error(Unix.ENOTCONN,_,_) ->
+ | Unix.Unix_error((Unix.ENOTCONN|Unix.EINVAL),_,_) ->
(* ENOTCONN is special because we allow to set the peer address
per datagram in this case!
*)
@@ -552,9 +552,10 @@
`Sockaddr(Unix.getpeername fd)
with
(* also catching ENOTCONN - which might happen for strange socket
- implementations
+ implementations. EINVAL is thrown on MacOS 10.5 instead of ENOTCONN
*)
- | Unix.Unix_error((Unix.EAFNOSUPPORT|Unix.EOPNOTSUPP|Unix.ENOTSOCK|Unix.ENOTCONN),
+ | Unix.Unix_error((Unix.EAFNOSUPPORT|Unix.EOPNOTSUPP|Unix.ENOTSOCK|
+ Unix.ENOTCONN|Unix.EINVAL),
_,_) -> `Implied in
let mplex =
Uq_engines.create_multiplex_controller_for_connected_socket
patch-uq_engines.ml.diff
(application/octet-stream, 1.4 KB)
--- src/equeue/uq_engines.ml.orig 2009-02-03 16:17:18.000000000 +0000
+++ src/equeue/uq_engines.ml 2009-02-03 16:18:51.000000000 +0000
@@ -1456,7 +1456,7 @@
(* fd is a connected socket *)
`Recv_send addr
with
- | Unix.Unix_error(Unix.ENOTCONN,_,_) ->
+ | Unix.Unix_error((Unix.ENOTCONN|Unix.EINVAL),_,_) ->
(* fd is an unconnected socket *)
`Recvfrom_sendto
| Unix.Unix_error(Unix.ENOTSOCK,_,_) ->
@@ -2329,7 +2329,7 @@
ignore(Unix.getpeername s);
`Done(`Socket(s, getsockspec stype s))
with
- | Unix.Unix_error(Unix.ENOTCONN,_,_) ->
+ | Unix.Unix_error((Unix.ENOTCONN|Unix.EINVAL),_,_) ->
(* We did not succeed connecting. ENOTCONN is just a
* substitute error code, not the real error, however.
*)
@@ -2349,7 +2349,7 @@
ignore(Unix.getpeername s);
`Done(`Socket(s, getsockspec stype s))
with
- | Unix.Unix_error(Unix.ENOTCONN,_,_) ->
+ | Unix.Unix_error((Unix.ENOTCONN|Unix.EINVAL),_,_) ->
(* See comment above *)
`Error (getconnerror s)
| error ->
@@ -2503,7 +2503,7 @@
let ps =
try getpeerspec Unix.SOCK_STREAM sock'
with
- | Unix.Unix_error(Unix.ENOTCONN,_,_) as e ->
+ | Unix.Unix_error((Unix.ENOTCONN|Unix.EINVAL),_,_) as e ->
Unix.close sock';
raise e in
acc_engine <- None;