[FreeNX-kNX] Sanity check...
Ed Warnicke
eaw at cisco.com
Sat Apr 23 21:04:55 UTC 2005
On Saturday 23 April 2005 10:41 am, you wrote:
> Am Samstag, 23. April 2005 17:32 schrieb Ed Warnicke:
> > On Saturday 23 April 2005 07:03 am, Fabian Franz wrote:
> > I dug into this more after I sent the email.
> > As it turns out there is a race condition between
> > nc and the starting of the nxagent by nxnode.
>
> Good catch! This should solve many more problems.
>
> > If nxagent isn't ready to accept the connection
> > from nc when the nc call is made, then nc quietly
> > exits and you fail in negotiating link parameters.
> > This failure is partially masked by the 'NX>'
> > error. I debuged this with something like
>
> Great.
>
> > log "netcat started"
> > netcat [...]
> > log "netcat finished with exit code $?"
> >
> > which showed an exit code of 1. After that
> > line you saw the 'NX> [...]" lines associated with
> > nxagent listening for connections.
>
> Ok.
>
> > Trying
> >
> > sleep 3; netcat [...]
> >
> > fixed the problem (which for some reason was
> > reliably occuring for me last night).
>
> Thats great :-). I mean: How could you have debugged it else ;-)?
>
> > So I am pretty
> > sure there is a race condition between calling
> > nc in nxserver and the nxagent started by nxnode
> > listening.
> >
> > I don't think a sleep is the right solution
> > though. Thoughts?
>
> Yes:
>
> TRY=3
> while [ $TRY -gt 0 ]
> do
> netcat && break
> sleep 1
> let TRY=$TRY-1
> done
> if [ $TRY -eq 0 ]
> then
> echo "NX> 550 Error: nxagent failed to start after three tries." 1>&2
> fi
Wouldn't it be a better solution to move the:
NX> 710 Session status: running
into the monitor if clause:
if stringinstring "Info: Waiting for connection from" "$line"
That way you would never get the nxclient sending
"bye" before the nxagent was actually up and awaiting
connections? This *should* also take care of the spurious
"NX>" problem as well.
You could then have your netcat line be something like:
netcat 127.0.0.1 $PROXY_DISPLAY &
echo_x "Bye"
echo_x "NX> 999 Bye"
wait $!
so that nxserver ONLY responds to nxclient with it's
Bye message once all of the pipes are hooked up.
(Please note, the above example is very rough,
you'd want to check various exit code to make
sure the pipe really are hooked up.)
Thoughts?
Ed
More information about the FreeNX-kNX
mailing list