Bug 22975

Summary: xdg-mime takes 15 seconds due to kdeinit/ktradertest bug in KDE4
Product: Portland Reporter: mdm
Component: xdg-utilsAssignee: Fathi Boudra <fabo>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: medium CC: pablo
Version: unspecifiedKeywords: patch
Hardware: Other   
OS: All   
Whiteboard:
i915 platform: i915 features:
Bug Depends on:    
Bug Blocks: 23105    
Attachments: patch to xdg-mime to work around kdeinit/ktradertest bug in KDE4

Description mdm 2009-07-27 15:03:50 UTC
Created attachment 28052 [details] [review]
patch to xdg-mime to work around kdeinit/ktradertest bug in KDE4

Under KDE, xdg-mime will use ktradertest to look up MIME handlers. In KDE4, ktradertest starts kdeinit (with --suicide --new-startup) if there is not already a running instance around (which, apparently, there is usually not). This copy of kdeinit will persist for about 15 seconds after it is last needed, presumably as an optimization to allow several clients to use the same instance.

However, kdeinit does not close its standard output, so when ktradertest is piped into grep by xdg-mime, grep will not exit until the kdeinit process started by ktradertest exits (because kdeinit still has grep's standard input open, even after ktradertest has exited). This causes xdg-mime to take about 15 seconds!

The true fix for this is to fix kdeinit/ktradertest, but xdg-mime can and probably should work around it by running a "patsy" version of ktradertest just to get kdeinit to start.

Patch attached.

We ran into this bug in Chromium, in the default browser detection code. See http://code.google.com/p/chromium/issues/detail?id=17179 for reference.
Comment 1 Fathi Boudra 2009-07-28 04:20:33 UTC
for the record, KDE bug:
http://bugs.kde.org/show_bug.cgi?id=201714

ktradertest is a KDE 3 only utility. On KDE 4, ktraderclient replaces it.
Comment 2 Fathi Boudra 2009-07-28 06:17:06 UTC
ktraderclient is now used under KDE 4 session (fixed in CVS).

On KDE 3, the pair is ktradertest/kdeinit.
On KDE 4, the pair is ktraderclient/kdeinit4.

I _guess_ you have some KDE 3 bits and you're running a KDE 4 session.
The call to ktradertest starts kdeinit and there isn't a running instance as you're not running a KDE 3 session.

is the bug still reproducible with current fix from CVS ?
Comment 3 mdm 2009-07-30 13:59:30 UTC
Not the original bug, no, but now there's a syntax error on line 537 of xdg-mime where there are a bunch of commented lines inside an if statement. Putting "true" in there fixes the syntax, but that part of the code is what would set the default application for a MIME type in KDE4. So there's some work to be done yet to implement that.

Interestingly ktradertest gives different results than ktraderclient, and they're apparently wrong (comparing to KDE4's system settings GUI), even after causing this 15 second delay. So ktraderclient is definitely the thing to do here.
Comment 4 Fathi Boudra 2009-07-30 23:50:35 UTC
(In reply to comment #3)
> Not the original bug, no, but now there's a syntax error on line 537 of
> xdg-mime where there are a bunch of commented lines inside an if statement.
> Putting "true" in there fixes the syntax, but that part of the code is what
> would set the default application for a MIME type in KDE4. So there's some work
> to be done yet to implement that.

true, I'm on it right now.
until it's properly fixed, I removed the unused code to avoid the syntax error.

> Interestingly ktradertest gives different results than ktraderclient, and
> they're apparently wrong (comparing to KDE4's system settings GUI),
> even after causing this 15 second delay. So ktraderclient is definitely the
> thing to do here.

I didn't expect using ktraderclient under KDE4 still causes the 15s delay or wrong output ...

Comment 5 mdm 2009-07-31 10:46:37 UTC
(In reply to comment #4)
> > Interestingly ktradertest gives different results than ktraderclient, and
> > they're apparently wrong (comparing to KDE4's system settings GUI),
> > even after causing this 15 second delay. So ktraderclient is definitely the
> > thing to do here.
> 
> I didn't expect using ktraderclient under KDE4 still causes the 15s delay or
> wrong output ...

It doesn't. Sorry I didn't make that clear. I was just observing how broken ktradertest is on KDE4. Using ktraderclient works fine.
Comment 6 Fathi Boudra 2009-08-03 05:24:28 UTC
I guess we can consider this bug fixed in CVS.
Comment 7 Pablo Castellano (pablog) 2010-01-24 05:02:39 UTC
(In reply to comment #6)
> I guess we can consider this bug fixed in CVS.
> 

Close?

Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.