[FreeNX-kNX] nxagent hangs on suspend when client nxssh destroyed

Mario Becroft mb at gem.win.co.nz
Mon Jul 27 14:24:16 UTC 2009


I did further investigation on the problem originally reported here:

http://mail.kde.org/pipermail/freenx-knx/2009-March/007964.html

as "nxagent hangs after suspending, cannot resume, watchdog thread
stuck"

It turns out that the problem occurs only when the nx session was ended
by destroying the client nxssh window.

Usually, this works fine, but occasionally the NX transport fails to
tear down correctly after NXTransDestroy(), leaving the nxagent waiting
forever in WaitCleanup().

Prior to waiting it starts a watchdog process which is meant to exit if
it times out, triggering the nxagent to forcibly tear down the
connections. However, in the freenx configuration this timeout is set to
0, meaning no timeout. This causes the watchdog process to never trigger
and thus nxagent hangs forever. According to the comments in
nxcomp/Control.cpp this is the intended behaviour, but it seems wrong,
since in this case we want the nxagent to give up and close the
connection if it fails to shut down properly. This timeout is controlled
by the cleanup option which nxnode sets to 0.

I have patched nxnode to set the timeout to 10 seconds. On our 50 user
production site this appears to have fixed the problem. Normally it
happens about 5 times per day; now it never happens.

I have not looked into why the normal teardown process fails. It is
probably a race condition or timing-sensitive somewhere since it seems
to occur more frequently when the freenx server is under load. But I
figure there could be various reasons why the connection might get stuck
and it is best that the watchdog is enabled to deal with whatever
problem might arise.

Patch included below for reference. I'm not sure whether this should be
included in mainline but on our site, at least, it certainly behaves
better with this patch.

--8<---------------cut here---------------start------------->8---
--- nxnode.1	2009-07-27 04:29:53.872607895 +1200
+++ nxnode	2009-07-27 04:29:56.932601326 +1200
@@ -1259,7 +1259,7 @@
 	umask 0077
 
 cat << EOF > "$USER_FAKE_HOME/.nx/C-$sess_id/options"
-nx/nx,${keyboard:+keyboard=$keyboard,}${kbtype:+kbtype=$kbtype,}${kbload:+kbload=$kbload,}${keymap:+keymap=$keymap,}${geometry:+geometry=$geometry,}${client:+client=$client,}${resize:+resize=$resize,}${CACHE}${IMAGES}${PACK}link=$link,nodelay=$nodelay,type=$realtype${clipboard:+,clipboard=$clipboard}${composite:+composite=$composite},cleanup=0,product=LFE/None/LFEN/None,shmem=1,${backingstore:+backingstore=$backingstore,}shpix=1,${ACCEPT}cookie=$proxy_cookie,id=$sess_id,samba=$samba,media=$media${sync:+,sync=$sync}${cups:+,cups=$cups}${keybd:+,keybd=$keybd}${aux:+,aux=$aux}${http:+,http=$http}${rdpcolors:+,rdpcolors=$rdpcolors}${rdpcache:+,rdpcache=$rdpcache}${fullscreen:+,fullscreen=1}${menu:+,menu=$menu}:$display
+nx/nx,${keyboard:+keyboard=$keyboard,}${kbtype:+kbtype=$kbtype,}${kbload:+kbload=$kbload,}${keymap:+keymap=$keymap,}${geometry:+geometry=$geometry,}${client:+client=$client,}${resize:+resize=$resize,}${CACHE}${IMAGES}${PACK}link=$link,nodelay=$nodelay,type=$realtype${clipboard:+,clipboard=$clipboard}${composite:+composite=$composite},cleanup=10,product=LFE/None/LFEN/None,shmem=1,${backingstore:+backingstore=$backingstore,}shpix=1,${ACCEPT}cookie=$proxy_cookie,id=$sess_id,samba=$samba,media=$media${sync:+,sync=$sync}${cups:+,cups=$cups}${keybd:+,keybd=$keybd}${aux:+,aux=$aux}${http:+,http=$http}${rdpcolors:+,rdpcolors=$rdpcolors}${rdpcache:+,rdpcache=$rdpcache}${fullscreen:+,fullscreen=1}${menu:+,menu=$menu}:$display
 EOF
 	umask $OLD_UMASK
 #samba=$samba,
--8<---------------cut here---------------end--------------->8---

-- 
Mario Becroft <mb at gem.win.co.nz>



More information about the FreeNX-kNX mailing list