Closed rgrinberg closed 9 years ago
No, Imap.run
does not do any I/O and should never block. If it does, it is a bug (an infinite loop somewhere). I'm busy right now but I will study your code later and get back sometime today.
Ok, I found it - you need to add
Imap.dst conn.connection conn.out 0 (Bytes.length conn.out);
just after between line 78 and line 79:
https://gist.github.com/rgrinberg/0e3860109c0f0fa66487#file-async_imap-ml-L78
Note that this is also in the example code:
https://github.com/nojb/ocaml-imap/blob/master/test/imap_shell.ml#L62
This looks like a bug (handling an output buffer of size 0); have to investigate further for the proper fix.
:trophy:
Awesome. That does the trick. Thanks!
I just pushed a fix for this. Thanks for reporting!
Great, hanks. Will give it a try ASAP.
I'm trying to get a sample that logs into gmail running using async rather than Lwt and it's modeled after
imap_shell.ml
. However, the code seems to get stuck on the login phase from what appears to be theImap.run
function. This surprises me a little because I don't expectImap.run
to do any IO or block. Am I misunderstanding something. The code in question is here (basically an async port of yourhandle
function with some debugging sprinkled in):A sample run gives:
Which to me looks like
Imap.run
never returns because I don't see the 2ndNEVER REACHES THE 2ND TIME
.Any idea what could be the problem?
Full code is here if you want to try it out: https://gist.github.com/rgrinberg/0e3860109c0f0fa66487