Skip Menu |

This queue is for tickets about the Mail-IMAPClient CPAN distribution.

Report information
The Basics
Id: 55527
Status: resolved
Priority: 0/
Queue: Mail-IMAPClient

People
Owner: PLOBBES [...] cpan.org
Requestors: nine [...] detonation.org
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: 2.2.2
Fixed in: 3.24



Subject: Mail::IMAPClient does not disconnect during DESTROY
According to the documentation: "Per RFC2683, Mail::IMAPClient will attempt to log out of the server during DESTROY if the object is in the ``Connected'' state." This does not happen. In fact, Mail::IMAPClient does not even contain a DESTROY method. This leads to webmail clients like CiderWebmail leaking IMAP connections.
Thank you for reporting this bug. This behavior apparently changed in the rewrite from 2.x to 3.x, I believe for backwards compatibility we should reinstate this behavior. I'll look to patch this in the next release. Show quoted text
> This leads to webmail clients like CiderWebmail leaking IMAP
connections. I'm not sure why this would "leak connections" at least from the webmail client side. I don't believe there should be any resource leak here per se. Care to elaborate? The objects are still destroyed on the client side, no? I could see this leaving extra open connections on the IMAP server until it realizes the client went away but maybe I'm missing something?
Subject: Re: [rt.cpan.org #55527] Mail::IMAPClient does not disconnect during DESTROY
Date: Thu, 18 Mar 2010 22:12:20 UT
To: bug-Mail-IMAPClient [...] rt.cpan.org
From: nine [...] detonation.org
Show quoted text
> I could see this leaving extra open connections on the IMAP > server until it realizes the client went away but maybe I'm missing > something?
That's exactly what I was trying to say. The IMAP server had these open connections till they timed out. If you open a connection for every single action in the webmail app, these can stress any mail_max_userip_connections setting... Thanks for fixing :)
On Thu Mar 18 18:12:52 2010, NINE wrote: Show quoted text
> > I could see this leaving extra open connections on the IMAP > > server until it realizes the client went away but maybe I'm missing > > something?
> > That's exactly what I was trying to say. The IMAP server had these > open connections till they timed out. If you open a connection for > every single action in the webmail app, these can stress any > mail_max_userip_connections setting... > > Thanks for fixing :)
I finally had a chance to dig into this a little. It appears the documentation has been wrong since perhaps 2.2.2 or earlier. There has been no automatic LOGOUT on DESTROY for a very long time from what I can tell. In rfc2683 section 3.1.2 (Severed connections) I see: " ... The client should send a LOGOUT command ... there isn't universal agreement here. Some contend that sending the LOGOUT and waiting for the two responses (untagged BYE and tagged OK) is wasteful and unnecessary, and that the client can simply close the socket. ..." This current behavior avoids the potentially wasteful/unnecessary requests and I believe the current behavior should not change for two reasons: 1) implementation history (despite contradictory documentation) 2) efficiency. Certainly the documentation should be corrected to match actual behavior that has been around for a long time. I did a brief test (one w/SSL, one without) and when a Mail::IMAPClient object goes out of scope the connection is implicitly close() and that close was seen by my test dovecot server immediately. I am not sure of the details of your tests/use-case but I did peek at the CiderWebmail code. Perhaps you are doing something different and thus seeing different behavior? If you can provide evidence that you think provides a convincing argument to change the current behavior I'm willing to listen. Are you sure CiderWebmail isn't keeping that "stashed" imapclient object around for a long time (e.g. until a session times out or expires)? I get the feeling that perhaps you're dealing with a CiderWebmail bug and not a Mail::IMAPClient bug... but I didn't dig to deep so perhaps I'm off- base here. If you're looking for options/workarounds: * make your own class using Mail::IMAPClient as a base class and provide your own DESTROY method that does what you want * call LOGOUT explicitly before destroying/undef-ing the object * be sure no objects are getting cached / kept alive in your current code If you feel that something more than a documentation fix is called for here please speak up!
Version 3.24 is out with a documentation patch for this bug. Specifically, I updated logout documentation to correctly state that DESTROY is not used to force an automatic logout on DESTROY despite documentation that indicated otherwise. Looking back at older versions it seems that documentation has been wrong for a long time, perhaps going back to 2.2.2 or older. Please feel free to reopen if you feel this should be dealt with in some other way, thanks!