Closed Bug 1771409 Opened 2 years ago Closed 2 years ago

Detecting the need for and sending of imap SELECT to detect new mail is no longer needed by Charter/Spectrum

Categories

(MailNews Core :: Networking: IMAP, defect)

defect
Not set
critical

Tracking

(thunderbird_esr91 wontfix)

RESOLVED FIXED
103 Branch
Tracking Status
thunderbird_esr91 --- wontfix

People

(Reporter: gds, Assigned: gds)

References

Details

User Story

As for now, Oct 15, 2020, the fix associated with this bug and it's dependent bug (bug 1360117), which solves an issue with the Charter/Spectrum IMAP server, is no longer really needed. A new version of the Charter IMAP server (InterMail vM.9.01.00.036.1 201-2473-137-122-163) is now in use that resolves the issue.

The root of the problem was that when new mail is checked for, tb sends the NOOP imap command to Inbox and expects to see indications of new mail in the response. The charter server only responded with OK with no additional information so new mail was never detected unless tb was restarted or an imap SELECT of Inbox occurred by setting cached connection to 1 and moving to another folder and back to Inbox.  Now with the new version of the charter server this has been fixed and NOOP now responds with an indication of new mail.

In addition, the new server version does not respond to the imap ID command with the server version as with the old defective version. Now it just responds with NIL. So, even if the bug still existed in the new server version, the problem would not be "auto detected" since the string expected in pref mail.imap.force_select_detect is no longer returned by the ID command.

Anyhow, existing mobile.charter.net users will continue to work OK. New accounts setup for that server will now see the pref mail.server.serverX.force_select be set to "no-auto" which will cause tb to behave as all other IMAP servers and not do an imap SELECT when checking for new mail and just do a NOOP.

However, for existing mobile.charter.net users that currently have the automatically set pref mail.server.serverX.force_select set to yes-auto, it may be advantageous to reset this back to default "no-auto" and restart TB. With this setting new mail should be detected with much less network traffic. This is because an imap SELECT will no longer occur on checking for new mail and an imap FETCH of all the message flags for Inbox will no longer occur. Depending on how many messages there are in Inbox, this could be a significant network traffic reduction.

Note: It is still possibly to force a SELECT when checking for new messages in Inbox at any account's imap server by setting the appropriate pref mail.server.serverX.force_select to yes.

Attachments

(1 file, 2 obsolete files)

+++ This bug was initially created as a clone of Bug #1231592 +++

This removes the code to automatically detect servers that require an extra imap SELECT to successfully get new mail during runtime. It was added to support the imap server used by ISP Charter/Spectrum. It was made general so that other servers, depending on imap ID response, could also be supported via a matching preference text string. However, the server used by Charter/Spectrum has been updated and now does new mail detection properly with just imap NOOP as required by RFC 3501. (Charter/Spectrum server also no longer responds with an ID string.) This problem has never been seen with other servers so most of the code that handles this can be removed. I did leave in a single boolean pref "force_select" (defaulted to false) that can be manually set true just in case some non conformant server still needs this.

This acts upon bug 1231592 comment 156.
The Charter/Spectrum server no longer has the issue and I haven't heard any reports of other servers needing this feature so I think it's ok to remove this somewhat obscure feature from future releases.

Assignee: nobody → gds
Attachment #9278413 - Flags: review?(mkmelin+mozilla)
Comment on attachment 9278413 [details] [diff] [review]
1771409-remove-force-select-detection.patch

Review of attachment 9278413 [details] [diff] [review]:
-----------------------------------------------------------------

Thanks! r=mkmelin
Attachment #9278413 - Flags: review?(mkmelin+mozilla) → review+
Status: NEW → ASSIGNED
Target Milestone: --- → 102 Branch

You wrote:

I did leave in a single boolean pref "force_select" (defaulted to false) that can be manually set true just in case some non conformant server still needs this.

In the patch:

-NS_IMPL_SERVERPREF_STR(nsImapIncomingServer, ForceSelect, "force_select")
+NS_IMPL_SERVERPREF_BOOL(nsImapIncomingServer, ForceSelect, "force_select")

The fact that you use the exact same pref name as before concerns me, because it was string before and now it's boolean. Some users will still have values in their prefs.js . I don't know how the preferences API will react to that? Will it throw an exception on read? Will it delete the string preference? Did you test this?

Did you test this?

I did test it to make sure mail.server.default.force_select controlled whether the extra select is sent and it didn't crash. But I didn't try setting a specific mail.server.serverX.force_select to make sure serverX responds as expected. I have lots of accounts (servers) setup for testing and for each one I see in prefs.js and "Advanced Preferences" items like this (filtering on force_select) with the patch in effect:

mail.server.default.force_select false
mail.server.server1.force_select no-auto
mail.server.server12.force_select no-auto
mail.server.server21.force_select no-auto

The no-auto values are the string values from the release code. If I want to make server21 do the forced select with the patched code I have to "delete" the item in "Advanced Preferences" with the trash can icon, then change it from string to bool and add it back with + icon and set it to true and then restart TB. The old non-default string values don't automatically change to bool or automatically just get deleted. (The default item with the same name automatically changed from string to boolean: mail.server.default.force_select.)

Another thing to do might be to just change pref name from force_select to something else like force_select_imap. When I do this to override the default I have to create a new item such as mail.server.server21.force_select_imap as a boolean and set it true. However the old non-default strings like mail.server.server21.force_select no-auto are still present but cause no harm and can be manually deleted.

Anyhow, not sure which is best or if there is another way. Or maybe just remove the "force select" feature completely?

just change pref name from force_select to something else like force_select_imap

Yes, that's the safe way to do.

maybe just remove the "force select" feature completely?

Your call.

Attachment #9278413 - Flags: review-
See Also: → 1745205

Your call

I just went with changing the name from "force_select" to "force_select_imap"

Attachment #9278413 - Attachment is obsolete: true
Attachment #9278584 - Flags: review?(ben.bucksch)

Comment on attachment 9278584 [details] [diff] [review]
1771409-remove-force-select-detection-v2.patch

That's better, thanks Gene!

I'll let Magnus set his review flag again, because he did the initial review.

Attachment #9278584 - Flags: review?(mkmelin+mozilla)
Attachment #9278584 - Flags: review?(ben.bucksch)
Attachment #9278584 - Flags: review+
Comment on attachment 9278584 [details] [diff] [review]
1771409-remove-force-select-detection-v2.patch

Review of attachment 9278584 [details] [diff] [review]:
-----------------------------------------------------------------

Thanks, indeed that pref name rename was needed. r=mkmelin
Attachment #9278584 - Flags: review?(mkmelin+mozilla) → review+

I re-tested to make double sure the patch builds and works and it does.

I mentioned this above that it still leaves in the old mail.server.serverX.force_select string values that are now ignored in TB. These can optionally be deleted using "Advance Preferences/Config Editor".

In case someone wants to still do the force select on all imap servers, just set mail.server.default.force_select_imap in Advanced Preferences to true and restart TB.

If force select is only wanted for a particular account/server you have to determine the server/account number X by looking with Advance Preferences and enter mail.server.server and find the account number based on other info shown such as server name. Then in Advance Preference enter mail.server.serverX.force_select_imap (where X is the corresponding server/account number such as server12) and add it with the + icon and select it as boolean and set it true . Then restart tb and the imap select will occur on each check for new mail for server/account X only.

it still leaves in the old mail.server.serverX.force_select string values that are now ignored

That's fine, we have been doing that since 20 years. They don't cause any speed issue, and it might be useful for diagnosing in case something does go wrong (which we don't hope).

In case someone wants to still do the force select on all imap servers, just set mail.server.default.force_select_imap in Advanced Preferences to true and restart TB.

I think it's a safe approach, just in the case it might still be needed. If nobody needs this, we can take it out completely in the next release.

Well done, thank you, Gene!

Pushed by geoff@darktrojan.net:
https://hg.mozilla.org/comm-central/rev/5711dbdd2c78
Remove detection of need for forced imap select. r=BenB,mkmelin

Status: ASSIGNED → RESOLVED
Closed: 2 years ago
Resolution: --- → FIXED
Target Milestone: 102 Branch → 103 Branch

The test mailnews/imap/test/unit/test_imapID.js is now failing. Here's an sample log.

I'll likely back this patch out in a few hours unless there's a quick fix.

Flags: needinfo?(gds)

I took out the place where the ID response string got stored. It is now only used to check for a very old Zimbra server put in by Bienvenu that is broken for condstore so I didn't see the problem just running normally. Sorry, should have did a try or run the xpcshell-test. It now passes ./mach xpcshell-test comm/mailnews/imap/test/unit/test_imapID.js

The change in the patch is here in nsImapProtocol.cpp (marked below with <----):

@@ -8196,78 +8148,23 @@ void nsImapProtocol::ProcessAfterAuthent
   // backend.  If we enable compression early the proxy
   // will be confused.
   if (UseCompressDeflate()) StartCompressDeflate();
 
   if ((GetServerStateParser().GetCapabilityFlag() & kHasEnableCapability) &&
       UseCondStore())
     EnableCondStore();
 
-  bool haveIdResponse = false;
   if ((GetServerStateParser().GetCapabilityFlag() & kHasIDCapability) &&
       m_sendID) {
     ID();
-    if (m_imapServerSink && !GetServerStateParser().GetServerID().IsEmpty()) {
-      haveIdResponse = true;
-      // Determine value for m_forceSelect based on config editor
-      // entries and comparison to imap ID string returned by the server.
+    if (m_imapServerSink && !GetServerStateParser().GetServerID().IsEmpty())    <-----
       m_imapServerSink->SetServerID(GetServerStateParser().GetServerID());      <-----
Attachment #9278584 - Attachment is obsolete: true
Flags: needinfo?(gds)
Attachment #9278865 - Flags: review?(mkmelin+mozilla)
Comment on attachment 9278865 [details] [diff] [review]
1771409-remove-force-select-detection-v3.patch

Review of attachment 9278865 [details] [diff] [review]:
-----------------------------------------------------------------

Thanks, looks ok try as well!

Gene: please consider switching to using moz-phab. Setting up and learning it is 10min very well spent - https://moz-conduit.readthedocs.io/en/latest/phabricator-user.html
Attachment #9278865 - Flags: review?(mkmelin+mozilla) → review+
Pushed by mkmelin@iki.fi:
https://hg.mozilla.org/comm-central/rev/d290d9886eb6
Backed out changeset 5711dbdd2c78 for test failures. r=backout
https://hg.mozilla.org/comm-central/rev/09164b65684e
Remove detection of need for forced imap select. r=BenB,mkmelin
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: