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/TChannelTransport.ml b/lib/ocaml/src/TChannelTransport.ml
index 89ae352..5407a8e 100644
--- a/lib/ocaml/src/TChannelTransport.ml
+++ b/lib/ocaml/src/TChannelTransport.ml
@@ -3,14 +3,18 @@
class t (i,o) =
object (self)
+ val mutable opened = true
inherit Transport.t
- method isOpen = true
+ method isOpen = opened
method opn = ()
- method close = ()
+ method close = close_in i; opened <- false
method read buf off len =
- try
- really_input i buf off len; len
- with _ -> T.raise_TTransportExn ("TChannelTransport: Could not read "^(string_of_int len)) T.UNKNOWN
+ if opened then
+ try
+ really_input i buf off len; len
+ with _ -> raise (T.E (T.UNKNOWN, ("TChannelTransport: Could not read "^(string_of_int len))))
+ else
+ raise (T.E (T.NOT_OPEN, "TChannelTransport: Channel was closed"))
method write buf off len = output o buf off len
method flush = flush o
end