KWallet hang mixing synchronous and asynchronous wallet opening

Richard Smith kde at metafoo.co.uk
Fri Jan 30 20:30:00 GMT 2004


Hi again,

On Thursday 29 January 2004 7:22 pm, Richard Smith wrote:
> While trying to transition some code to using asynchronous KWallet opening,
> I ran across a problem. The code, cut down to its simplest form (attached -
> needs an admin/ dir copied in) opens the wallet asynchronously, then,
> before the open call succeeds, opens it again synchronously. The result is
> the following:
>
> If the user chooses to open the wallet, the synchronous openWallet call
> succeeds but the asynchronous wallet never emits the walletOpened() signal.
> If the user chooses not to open the wallet, the synchronous openWallet call
> never returns and the program hangs.

Further investigation has turned up three distinct bugs. The attached patch 
fixes them all. Here they are:

1: One app opens the wallet asynchronously then, while waiting for the result, 
another app opens it synchronously. The user declines to open the wallet.
=> An infinite loop is entered in open().
=> KWalletD hangs.
=> KDED hangs.
=> KDE hangs.

The fix: make the loop not infinite :)

2: One app opens the wallet asynchronously then, while waiting for the result, 
opens it synchronously. The user declines to open the wallet.
=> The synchronous request's transaction is thrown away.
=> No reply is sent to the application.
=> The server leaks memory and the client hangs.

The fix: instead of throwing away the transaction, mark it as having failed, 
and send a reply later.

3: One app opens the wallet asynchronously then, while waiting for the result, 
opens it synchronously. The user allows the wallet to be opened.
=> The second call overwrites the first one's dcop client.
=> No reply is sent to the asynchronous call.

The fix: in openAsynchronous(), store the sender's name before calling the 
open() function.

There's more to be done here. There are a few other things that look like they 
might break, but so far I've not been able to reproduce any other bugs. 
Anyway, these are stopping me from making progress Right Now, and IMO need to 
go into 3.2 final.

So... is this OK to commit into HEAD? Into BRANCH?

Richard

PS, if anyone wants to do any playing, I have a test suite with three 
programs, one which opens the wallet synchronously, one asynchronously, and 
one nesting a sync call inside an async one. I'm happy to post, or upload to 
CVS, on request.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: kwalletd-more-async-fix.diff
Type: text/x-diff
Size: 2263 bytes
Desc: not available
URL: <http://mail.kde.org/pipermail/kde-core-devel/attachments/20040130/39fb32ad/attachment.diff>


More information about the kde-core-devel mailing list