Bug 117434

Summary: long delay when activating /usr/lib/powersave/do_screen_saver
Product: [openSUSE] SUSE Linux 10.1 Reporter: Harald Koenig <koenig>
Component: Mobile DevicesAssignee: Forgotten User ZhJd0F0L3x <forgotten_ZhJd0F0L3x>
Status: RESOLVED WONTFIX QA Contact: E-mail List <qa-bugs>
Severity: Normal    
Priority: P5 - None CC: behlert, dkukawka, kde-maintainers, m.camen
Version: Final   
Target Milestone: ---   
Hardware: i686   
OS: All   
Whiteboard:
Found By: Other Services Priority:
Business Priority: Blocker: ---
Marketing QA Status: --- IT Deployment: ---

Description Harald Koenig 2005-09-16 08:58:50 UTC
/usr/lib/powersave/do_screen_saver uses get_x_users() from
/usr/lib/powersave/scripts/x_helper_functions  (powersave-0.10.15-5)
to check, if KDE is running with

        /opt/kde3/bin/dcopfind kdesktop

on my idle notebook with xfce4 this takes 13-14 seconds, so there is a huge delay
before xlock gets started  (you may consider this a 13 secs security risk if it
helps
to change that code in 10.0 ;-).


what about the following possibilties to check for a running KDE

        su ${X_USERS[$i]} -c "DISPLAY=${DISPS[$i]} xlsclients -al | grep -q '^ 
Name:  kicker' "  && ...
or
        su ${X_USERS[$i]} -c "DISPLAY=${DISPS[$i]} xwininfo -all -root | grep -q
grep "\"Kdesktop\"  && ...
        su ${X_USERS[$i]} -c "DISPLAY=${DISPS[$i]} xwininfo -all -root | grep -q
grep "\"kdesktop\"  && ...
        su ${X_USERS[$i]} -c "DISPLAY=${DISPS[$i]} xwininfo -all -root | grep -q
grep "'"kdesktop": ("kdesktop" "Kdesktop")' && ...

these all are _much_ faster if KDE is not running...


right now I'm happilyusing the last of those tests,
Comment 1 Forgotten User ZhJd0F0L3x 2005-09-16 09:27:43 UTC
Any ideas by our KDE gurus why 

        /opt/kde3/bin/dcopfind kdesktop

takes 14 seconds if no KDE is running? And if we should go for

        xwininfo -all -root | grep -q "kdesktop"

instead?
Comment 2 Harald Koenig 2005-09-16 09:34:36 UTC
(In reply to comment #1)
> if we should go for
> 
>         xwininfo -all -root | grep -q "kdesktop"
> 
> instead?

please note that all the quotes in my examples above have been used
deliberately. your example will match and give a "false positive" KDE runnning
e.g. for

   xemacs kdesktop &


 
Comment 3 Marcus Camen 2005-09-16 18:02:44 UTC
Why not just check for  
 $KDE_FULL_SESSION = true  
which is defined in startkde? 
 
http://lxr.kde.org/search?v=3.4-branch&filestring=&string=KDE_FULL_SESSION 
 
Comment 4 Forgotten User ZhJd0F0L3x 2005-09-16 20:06:13 UTC
(In reply to comment #3)
> Why not just check for  
>  $KDE_FULL_SESSION = true  
> which is defined in startkde? 

The scripts are not running as the logged in user, and not from the logged in
session.
Powersaved's environment does not get $KDE_FULL_SESSION from init.
Comment 5 Marcus Camen 2005-09-17 21:04:48 UTC
> The scripts are not running as the logged in user, and not from the logged in
> session.

/me RTFscript...  ...ah, ok.

Just a comment:
I think what happens is the following: dcopfind tries to open
$HOME/.DCOPserver_`hostname`__0 (for $DISPLAY=:0.0).
On a stock 10.0 this file exists and has 'valid content' when running KDE. Thus
dcopfind returns immediately. When running xfce this file does not exist and
dcopfind also returns immediately.
Let's say for whatever reason a user is not running KDE but the .DCOPserver*
file exists nevertheless. Well, there you have the long delay.

Judging from a few 'real world' homedirectories orphaned .DCOPserver* files seem
to be not too uncommon (maybe because of crashing KDE sessions?). So, although
you won't see this bug on a fresh 10.0 installation I assume you will see users
running into it from time to time.
Comment 6 Harald Koenig 2005-09-19 12:39:00 UTC
(In reply to comment #5)

> I think what happens is the following: dcopfind tries to open
> $HOME/.DCOPserver_`hostname`__0 (for $DISPLAY=:0.0).
> On a stock 10.0 this file exists and has 'valid content' when running KDE. Thus
> dcopfind returns immediately. When running xfce this file does not exist and
> dcopfind also returns immediately.

indeed!  today, after a fresh reboot, I cannot reproduce the long timeout for
dcopfind with xfce4 right now.  too bad I did not run strace that time to figure
out why/where it did hang:-(  I'll try again later...

> you won't see this bug on a fresh 10.0 installation I assume you will see users
> running into it from time to time.

yep
Comment 7 Forgotten User ZhJd0F0L3x 2005-10-30 09:34:58 UTC
Holger, let's discuss / incorporate the fixes from the bug description for 10.1, there was no objection from the KDE team.
Comment 10 Harald Koenig 2006-06-06 12:02:08 UTC
(In reply to comment #7)
> Holger, let's discuss / incorporate the fixes from the bug description for
> 10.1, there was no objection from the KDE team.

last weekend I updated my notebook to 10.1 -- and realized that this fix didn't make it into 10.1 :-((

10.1 get_x_users() in x_helper_functions still calls dcopfind and hangs :-(
Comment 11 Stefan Behlert 2006-10-18 12:38:38 UTC
Anything new here, this bug is now inactive for quite some time. Is this fixed for 10.2?
Comment 12 Forgotten User ZhJd0F0L3x 2006-10-18 12:57:08 UTC
fixed in the sense of "the code will not be used anymore"
Comment 13 Dirk Mueller 2006-10-18 14:20:33 UTC
I still have the same problem even when using plain xlock. 
Comment 14 Forgotten User ZhJd0F0L3x 2006-10-18 16:01:42 UTC
Well, this code will not be used in 10.2 anymore. Only kpowersave or gnome-power-manager users will get "Lock X before suspend" functionality, so this code will never be executed again.
Comment 15 Harald Koenig 2006-10-26 11:58:29 UTC
(In reply to comment #14)
> Well, this code will not be used in 10.2 anymore. Only kpowersave or
> gnome-power-manager users will get "Lock X before suspend" functionality, so
> this code will never be executed again.

and for all other desktops (e.g. xfce4, fvwm2, ...) the xlock-on-suspend will silently be removed in 10.2 ???  

IMHO that would be very pitty!!
Comment 16 Forgotten User ZhJd0F0L3x 2006-10-30 10:43:05 UTC
well, to suspend you will need to call "powersave -{U,u}" anyway, so you can also call "xlock&powersave -u".
There will not be much left of powersave after we transition to pm-utils.