Thrift: OCaml TSocket fix
Summary: Now closes input channel on close. Also, transport exceptions are cleaner.
Reviewed by: mcslee
Test plan: Yes
Revert plan: yes
git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@665198 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/lib/ocaml/src/Thrift.ml b/lib/ocaml/src/Thrift.ml
index 8ff5fa9..92c015b 100644
--- a/lib/ocaml/src/Thrift.ml
+++ b/lib/ocaml/src/Thrift.ml
@@ -9,11 +9,6 @@
method set_message s = message <- s
end;;
-exception TExn of t_exn;;
-
-
-
-
module Transport =
struct
type exn_type =
@@ -23,19 +18,7 @@
| TIMED_OUT
| END_OF_FILE;;
- class exn =
- object
- inherit t_exn
- val mutable typ = UNKNOWN
- method get_type = typ
- method set_type t = typ <- t
- end
- exception TTransportExn of exn
- let raise_TTransportExn message typ =
- let e = new exn in
- e#set_message message;
- e#set_type typ;
- raise (TTransportExn e)
+ exception E of exn_type * string
class virtual t =
object (self)
@@ -49,10 +32,7 @@
while !got < len do
ret := self#read buf (off+(!got)) (len - (!got));
if !ret <= 0 then
- let e = new exn in
- e#set_message "Cannot read. Remote side has closed.";
- raise (TTransportExn e)
- else ();
+ raise (E (UNKNOWN, "Cannot read. Remote side has closed."));
got := !got + !ret
done;
!got
@@ -260,7 +240,7 @@
| SIZE_LIMIT
| BAD_VERSION
- exception TProtocolExn of exn_type * string;;
+ exception E of exn_type * string;;
end;;
@@ -280,7 +260,7 @@
end
-
+(* Ugly *)
module Application_Exn =
struct
type typ=
@@ -336,7 +316,7 @@
let read (iprot : Protocol.t) =
let msg = ref "" in
let typ = ref 0 in
- iprot#readStructBegin;
+ ignore iprot#readStructBegin;
(try
while true do
let (name,ft,id) =iprot#readFieldBegin in