thinlocal needs to be able to determine if a session is on the local machine, or another agent. It needs this to determine if it needs to respool the job, or if it is ready to send it to the client.
Currently it does this by looking at the session's "termserv_hostname", and then using the same function the local agent uses to determine what the local "termserv_hostname" should be. This is based on the flawed assumption that this value never changes. E.g. we have bug 3419 and bug 4189 that will update the agent to notice these changes.
We are also considering moving the termserv_hostname translation to the master, which will completely break this method.
If we implement bug 4256, then this issue becomes trivial. If we don't, then we need something more creative.
One method would be this:
1) Specify that the name in /vsmservers/terminalservers (aka "agenthost") must be a local name for the agent (no proxies or NAT allowed).
2) Do a UDP connection to "agenthost".
3) Look at what the local socket address is.
If the session is local, then the local address should be "agenthost", or localhost.
We should probably move get_agent_hostname() into VSMAgent when we've fixed this.