a solution for bug 77862, kio_imap processes hang when connection status changes

Guy Maurel guy-kde at maurel.de
Fri Aug 6 17:33:43 BST 2010


Hello!

I post my solution for the bug 77862 here for two reasons:
1. It might be a better place to put the class under kdelibs, to be used by 
    other applications, not only kmail,
2. the KMail maintainer had no more time to evaluate and appreciate my
    proposal before he steps down the job.

The bug is more than 6 years old. It is an indice that nobody had time enough 
to work on it. I also spend about 5 months for this solution.

"... when connection status changes" This is really clear, and happens i.e. 
with a laptop if one changes his/her place.
The IP-address changes, the application cannot/may not use this connection any 
more.

It is not proprely an IMAP-bug. It is also not specialy a kmail-bug.
It is a networking-bug.

It might happens within every application which uses an IP-address.
This is why I would like to split my solution into two parts.

The first part proposes to introduce the class KIpAddressInUse.
With this class, we can:
- save the actually used IP-address by the connection
- check if the saved IP-address is still available
This part could be integrated into kdelibs and used by any application which  
uses of an IP-address.

The second part is my use of this at kmail, to solve the bug 77862.
(It could be an example for any other application).

kmail only need to:
- check the availibity of the IP-address each time
    _before_ using the socket to write to the IMAP-server and
    _before_ using the socket to read from the IMAP-server
If the socket is not available kmail:
- marks the error as ERR_CONNECTION_BROKEN and close the connection

Then kmail has to:
- check the state of the connection after each use of the socket                                    
  and return from the actual method/function ie.:                                                   
    if (getState () == ISTATE_NO) return ;                                                          
                                                                                                    
The rest of the work is already present at release 4.4:                                             
- SlaveBase::error                                                                                  
    sends a signal to the application.                                                              
- The application sends a DISCONNECT to the slave                                                   
    and cleans some data to be ready for the next connection.                                       
                                                                                                    
As defined at (4.4)imapaccountbase.h:533                                                                 
    /** used to send a noop to the slave in regular intervals to keep it from 
disconnecting */       
    QTimer mNoopTimer;                                                                              
and used at (4.4)kmacctimap.cpp:63                                                                       
    mNoopTimer.start( 60000 ); // // send a noop every minute                                       
The timer sends a NOOP-command after this time and defines two periods:
One before the NOOP, one after.                                                                     
                                                                                                    
Let us have a look to what appens when the IP-Address has changed.                                  
                                                                                                    
If the user makes an action with network traffic, this leads to a                                   
detection of the IP-Address and "killAllJobs" throws all the jobs and
clears the connection. The user must try again.

If the user action occurs after the NOOP, all is already clear.

Ready!
================

I put this proposal at the kde-pim-list on Sun, 11 Jul 2010.

Tests and comments are welcome.

Three attachments describe the class and a test for it.
Two attachments are the diffs from kdepim-4.4
-- 
guy
-------------- next part --------------
A non-text attachment was scrubbed...
Name: kipaddressinuse.h
Type: text/x-chdr
Size: 2139 bytes
Desc: not available
URL: <http://mail.kde.org/pipermail/kde-core-devel/attachments/20100806/b0558293/attachment.h>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: kipaddressinuse.cpp
Type: text/x-c++src
Size: 1928 bytes
Desc: not available
URL: <http://mail.kde.org/pipermail/kde-core-devel/attachments/20100806/b0558293/attachment.cpp>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: kipaddressinusetest.cpp
Type: text/x-c++src
Size: 1596 bytes
Desc: not available
URL: <http://mail.kde.org/pipermail/kde-core-devel/attachments/20100806/b0558293/attachment-0001.cpp>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: yaps-77862-kdepimlibs.diff
Type: text/x-patch
Size: 24401 bytes
Desc: not available
URL: <http://mail.kde.org/pipermail/kde-core-devel/attachments/20100806/b0558293/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: yaps-77862-kdepim.diff
Type: text/x-patch
Size: 338 bytes
Desc: not available
URL: <http://mail.kde.org/pipermail/kde-core-devel/attachments/20100806/b0558293/attachment-0001.bin>


More information about the kde-core-devel mailing list