nojb / ocaml-imap

Lwt-compatible IMAP4rev1 client library for OCaml
https://nojb.github.io/ocaml-imap/imap
Other
40 stars 17 forks source link

Unclosed channels #1

Closed rgunden closed 10 years ago

rgunden commented 10 years ago

This is a nice library. I'm using the async backend in a polling daemon that repeatedly connects/disconnect. I've noticed that the channels aren't getting closed. When I look at the code it seems Imap_asyc.close is a nop. Also the calls to IO.close are commented out in two places in client.ml. Just curious what the story behind this is? are there problems/bugs if we uncomment and redefine close?

nojb commented 10 years ago

Thanks for letting me know! Basically there should not be a problem closing the connection. Give me a few hours (I am terribly jet-lagged) and I will look into it.

nojb commented 10 years ago

I have added some code (b0133c283de1bba9e83fd7c8d0d0b96eab70f09b) to close the channels whenever a disconnect occurs. One thing that bothers me is that if I close both the input and the output channel, then the underlying file descriptor is closed twice, which doesn't seem right (it produces an error that gets ignored, but still). Also, I still feel that the division of responsabilities between of the abstract Imap library and its various backends (Imap_lwt, Imap_async, Imap_unix) is not quite right, so this is something that I will be thinking more about and may change the interface in the future. Please test this if you can and let me know if you seen any other problem. Thanks again!

rgunden commented 10 years ago

Thanks for the quick fix. Looks like its working nicely now.