Download & Extend

Mailhandler attempts to open server session twice

Project:Mailhandler
Version:6.x-1.8
Component:Code
Category:bug report
Priority:normal
Assigned:Unassigned
Status:closed (duplicate)

Issue Summary

In Mailhandler 6.x-1.8

I didn't see any other reports on this, so it may be related to the fact that I'm using hMailServer as my mail server in a windows development environment. Other servers may simply ignore the fact that a client is trying to open an already open session.

Nonetheless, my code review reveals that there is a flaw in Mailhandler's mail retrieval logic. mailhandler_cron_retrieve() calls mailhandler_get_unread_messages(). They are both calling mailhandler_open_mailbox(). The second call to mailhandler_open_mailbox() generates errors on my mail server and the session fails.

I've attached a patch file for mailhandler.retrieve.inc which corrects the situation.

AttachmentSize
mailhandler.retrieve.inc-20091003.patch1.54 KB

Comments

#1

Status:patch (to be ported)» postponed (maintainer needs more info)

@tjsaker I see what you are saying. It looks like your patch will cause mailhandler_open_mailbox to be called multiple times when running via cron. Can you try the following:

Change:

  if ($result = mailhandler_open_mailbox($mailbox)) {
    // Find out how many messages need retrieval
    $new_messages = mailhandler_get_unread_messages($mailbox);

to:

  $new_messages = mailhandler_get_unread_messages($mailbox);
  if ($result = mailhandler_open_mailbox($mailbox)) {
    // Find out how many messages need retrieval

and see if you still get the session error? mailhandler_get_unread_messages() closes the connection it opens. I'm wondering if it's called first, since it will not be opening a second connection to the mailbox, whether this will fix the problem you're seeing. I do not know how opening multiple streams to the same mailbox is handled b/t the different OS's. Please let me know how it goes.

#2

Status:postponed (maintainer needs more info)» closed (duplicate)

I believe this is a dupe of http://drupal.org/node/358737 ... marking it as such.

nobody click here