Bug 2991 - POP3 problems: POP3 sessions duplicated, and filtering issues
: POP3 problems: POP3 sessions duplicated, and filtering issues
Status: RESOLVED FIXED
Product: Claws Mail
Classification: Unclassified
Component: POP3
: 3.9.2
: PC Linux
: P3 normal
Assigned To: users
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2013-08-12 10:55 CEST by Paul Rolland
Modified: 2014-04-30 21:41 CEST (History)
2 users (show)

See Also:


Attachments
Patch to add a per-account lock to prevent two simultaneous POP3 sessions on the same account (2.26 KB, application/octet-stream)
2013-08-12 10:55 CEST, Paul Rolland
no flags Details
Patch to fix POP3 and processing issues (6.47 KB, patch)
2013-08-12 10:57 CEST, Paul Rolland
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Paul Rolland 2013-08-12 10:55:50 CEST
Created attachment 1294 [details]
Patch to add a per-account lock to prevent two simultaneous POP3 sessions on the same account

First, I have to say that they occur only while I'm in holidays: at that
time, my Internet access is an ultra slow GPRS access....

I'm using POP3, and I have several accounts configured. Each of them as a
default folder to drop emails. I also have filtering rules, some applying
to all the accounts, some only for specific accounts. Last, my "Default"
folder also has a processing rule to archive emails older than 32 days.

Problem #1:
  a) Claws is offline
  b) I connect to Internet using my GPRS modem. Due to the way I'm
     connecting,
     NetworkManager is not informed, and Claws is still offline.
  c) Turn Claws online,
  d) Receive messages for one account.
If the "Receive" operation I start manually last longer than this account
retrieve interval, and that this account is configured for automatic
retrieval, I end up with _two_ retrieve operations at the same time. I can
see by the "progress counters" at the bottom right of the Claws window
alternating their counts of messages, for example:
10/46 then 30/46 then 10/46 again, and so on.
When that happens, I kill Claws to avoid more mess...

Problem #2:
  a) Claws is online
  b) I start a "Receive all", still using my slow GPRS access. This first
     collect the emails from my professional account, and then it goes to a
     secondary account, which is subscribed to several mailing lists.
  c) While the retrieval on the secondary mailing list occurs, I reply to
     an email associated with the main account, and Send this email.
This "Send" action results in all the emails received so far for the
secondary account (POP still in progress) to be placed in the folder
associated with the main account (the one used for the Send). It may be
important to note that this account (used to Send) is also configured with
"Authenticate with POP before sending". Maybe the POP sessions are mixing
each other ?

After investigations, it seems that problem #1 can be easily reproduced:
 - claws mail is offline,
 - I turned it online,
 - I used the "Received mail from all accounts" and selected one account,
   to start a retrieve session on that account.
 - While it was running, I hit "F5" which is bound to
   Message > Receive > Get from all accounts

Nothing seems to be preventing two POP3 sessions for the same account to occur.
Adding a locking mechanism seems to be required.

Also, as nothing is also preventing simultaneous POP3 sessions on _different_ accounts, and because:
static gint inc_drop_message(Pop3Session *session, const gchar *file)
...
        /* CLAWS: claws uses a global .processing folder for the filtering. */
        dropfolder = folder_get_default_processing();

then everytime it happens that two (or more) POP3 sessions happens at the same time, messages filtering is causing bad results.
This could easily be solved using a per-account processing folder.

Attach to this post is a first patch that adds a flag in the PrefsAccounts. This flag is used to "lock" the POP3 session, thus avoiding it to be duplicated, while still allowing several POP3 on various accounts to be executed.
Comment 1 Paul Rolland 2013-08-12 10:57:47 CEST
Created attachment 1295 [details]
Patch to fix POP3 and processing issues

This second patch contains the previous one plus a proposal to have per-account processing folder, based on the account_id.
Comment 2 Paul 2013-10-02 10:08:53 CEST
I'm still not able to reproduce the problem you describe.
Comment 3 Paul Rolland 2013-10-02 15:06:29 CEST
Hi Paul,

Thanks for the feedback. 
I'm going to try to setup a configuration/test case that will allow to reproduce that easily. I think that inserting some delays in the POP server is likely to help creating the problem.

Please allow me a few days to setup that config, and I'll send you all the details.

Paul
Comment 4 Colin Leroy 2013-12-28 18:23:58 CET
Hi,

I've been able to do so, using the Get Mail arrow to fetch mail from my first account, immediately followed by Shift-A which is "Get for all accounts".
Comment 5 users 2013-12-28 18:57:35 CET
Changes related to this bug have been committed.
Please check latest Git and update the bug accordingly.
You can also get the patch from:
http://git.claws-mail.org/

++ ChangeLog	2013-12-28 18:57:35.500904730 +0100
http://git.claws-mail.org/?p=claws.git;a=commitdiff;h=e9ef0959dc55da5f723617f148e6184a64d11284
Merge: 766877a 6a4badf
Author: Colin Leroy <colin@colino.net>
Date:   Sat Dec 28 18:57:34 2013 +0100

    Merge branch 'master' of file:///home/git/claws

http://git.claws-mail.org/?p=claws.git;a=commitdiff;h=6a4badf693d075f151638f9497fa6b467e4d27b3
Author: Colin Leroy <colin@colino.net>
Date:   Sat Dec 28 18:31:22 2013 +0100

    Fix bug #2991, "POP3 sessions duplicated" on race conditions. Patch by
    Paul Rolland.

http://git.claws-mail.org/?p=claws.git;a=commitdiff;h=7bd41ae67a9fe6bd800d4cec9f2f1e012a244ba6
Author: Colin Leroy <colin@colino.net>
Date:   Sat Dec 28 18:15:31 2013 +0100

    Fix bug #3020, "Use theme doesn't change some icons until restart"

http://git.claws-mail.org/?p=claws.git;a=commitdiff;h=3d876eaf2fc33ebe36d36ca5d11a35b80868fee0
Author: Colin Leroy <colin@colino.net>
Date:   Sat Dec 28 18:10:26 2013 +0100

    Add Palmer Dabbelt to Authors

http://git.claws-mail.org/?p=claws.git;a=commitdiff;h=18696ff22a66c3d790abdc5f95b8ab5488ff2cb5
Author: Colin Leroy <colin@colino.net>
Date:   Sat Dec 28 18:08:38 2013 +0100

    Fix bug #3040, "Handle revoked GPG private keys". Patch by Palmer Dabbelt.

http://git.claws-mail.org/?p=claws.git;a=commitdiff;h=9a56118f8110ab403cb94547cca11c0cc3ab490c
Author: Colin Leroy <colin@colino.net>
Date:   Sat Dec 28 17:40:12 2013 +0100

    Fix bug #3038, "Select A Folder incorrectly matches on number
    in parentheses". Match on FolderItem's name instead of displayed
    string.

http://git.claws-mail.org/?p=claws.git;a=commitdiff;h=02b5ac9ed2d474e546a655c636e4c9e43dd3250b
Author: Colin Leroy <colin@colino.net>
Date:   Fri Dec 20 11:53:18 2013 +0100

    Add preference to allow disabling automatic drafting of encrypted
    messages.
Comment 6 Colin Leroy 2013-12-28 19:00:43 CET
Thanks for the patches :)
Comment 7 Colin Leroy 2014-04-30 21:41:56 CEST
*** Bug 2278 has been marked as a duplicate of this bug. ***