This project is read-only.

Content fetch goes into infinite loop

Topics: Issues
Nov 2, 2013 at 1:45 PM
There is a bug lurking in the code at ImapBase.cs in the following function:
public bool SendAndReceive(string command, ref ArrayList sResultArray)
    ...
    bool flag = true;
    while (flag)
    {
        string text2 = UseSSL ? ImapSslStreamReader.ReadLine() : ImapStreamReader.ReadLine();
        ...
        if (text2 != null)
        {
            ...
        }
    }
    ...
Please note that the ReadLine function may return only null sometimes, when the internet connectivity is not the best. During times like that, the flag variable is never set to false, and this goes into an infinite loop.

My suggestion is to change the above code to the following:
public bool SendAndReceive(string command, ref ArrayList sResultArray)
    ...
    bool flag = true;
    while (flag)
    {
        string text2 = UseSSL ? ImapSslStreamReader.ReadLine() : ImapStreamReader.ReadLine();
        ...
        if (text2 != null)
        {
            ...
        }
+       else
+       {
+           flag = false;
+           result = false;
+       }
    }
    ...
Best regards,
Soumya Dutta.
Coordinator
Nov 2, 2013 at 2:51 PM
Edited Nov 2, 2013 at 6:28 PM
Hi Soumya,

you're using the old version of ImapX, there were some changes done to the SendAndReceive method, please upgrade to ImapX 2.0.0.13.

However, you're right and the bug is also persistent in the new version. I will update the library. Thank you really much!

Best regards,

Pavel
Nov 3, 2013 at 12:22 AM
Hi Pavel,

Thanks for your prompt response in spite of your busy schedule. I shall await your update. May I expect this to be in 2.0.0.14?

Best regards,
Soumya Dutta.
Coordinator
Nov 3, 2013 at 10:00 AM
The code in the repository already contains a fix for this issue, and I'll update the binaries in download section today, so you don't have to wait until 2.0.0.14 is out, unless you want to use Nuget to install/update the library.

Kind regards,

Pavel
Dec 13, 2013 at 6:40 AM
Hi Pavel,
Please update the Nuget 2.0.0.13 with this latest change. The infinite loop is happening pretty often on a service I have running and having this fix through Nuget would really help.
Thanks
Paul
Coordinator
Dec 13, 2013 at 9:30 AM
Hi Paul,

i will publish the new release tonight and update the Nuget packages.

Greets,

Pavel