Subject: 25 user logon problem

From: Thomas Hanschke <[email-masked]>
Date: Thu, 28 Mar 2013 16:31:23 +0100

Package: x2goagent
Version: 2:3.5.0.17-0~320~precise1
        
I have 25 thinclients (wyse with windows7 embedded) in a classroom.
If more than 2 or 3 clients log on at exactly the same time, some of
them stop at the black screen before the gray X2Go Logo appears.
There is no error message. With a little timeshift of 2 or 3 seconds
between the logons, there are no problems.
          
I suggest a while-loop in x2gostartagent that looped through the
displays until it had a valid display and free ports.

I am using Ubuntu Version 12.04 (precise) (32-Bit),
Kernel Linux 3.2.0-39-generic-pae.
         
        Thanks for your help!
        Thomas

---

From: Mike Gabriel <[email-masked]>
Date: Mon, 15 Apr 2013 23:08:40 +0200

tag #155 moreinfo
thanks

Hi Thomas,

thanks for reporting the below issue.

> displays until it had a valid display and free ports.

I have attached a slightly modified x2gostartagent script and patch  
file that document the changes to this mail.

Please copy the x2gostartagent script to /usr/bin/x2gostartagent on  
the server and report back if the performed modification fixes your  
25-user-issue.

@Devs: I suspect we have to query x2gogetport 3x times during one run  
of x2gostartagent to make sure that more-than-one instances of  
x2gostartagent (run by different users at the very same time, a  
typical class room situation) do not interfere with each other. This  
probably has to happen in x2goresume-session, as well.

I am not 100% sure if the modified x2gostartagent reduces the reported  
issue to zero, but my guess is that the reported issue should go down  
in occurrence tremendously.

Please test with your setup and give feedback.

Greets+thanks,
Mike

-- 

DAS-NETZWERKTEAM
mike gabriel, rothenstein 5, 24214 neudorf-bornstein
fon: +49 (1520) 1976 148

GnuPG Key ID 0x25771B31
mail: [email-masked], http://das-netzwerkteam.de

freeBusy:
https://mail.das-netzwerkteam.de/freebusy/m.gabriel%40das-netzwerkteam.de.xfb

diff --git a/x2goserver/bin/x2gostartagent b/x2goserver/bin/x2gostartagent
index 45b3ba5..0d43de7 100755
--- a/x2goserver/bin/x2gostartagent
+++ b/x2goserver/bin/x2gostartagent
@@ -135,8 +135,7 @@ USED_DISPLAYS=`$X2GO_LIB_PATH/x2gogetdisplays $HOSTNAME`
 
 #Get all used in system ports from X2Go database and ss output
 ss=$(PATH="$PATH:/usr/sbin:/sbin" type -P ss);
-USED_PORTS=$(
-	"$X2GO_LIB_PATH/x2gogetports" "$HOSTNAME";
+USED_NONSSH_PORTS=$(
 	"$ss" -lnt |
 	perl -lne 'print$d{$2}="|$2|"if/^(\S+\s+){2}\S+:(\d+)/&&!exists$d{$2}';
 );
@@ -144,12 +143,12 @@ USED_PORTS=$(
 while [ "$OUTPUT"  != "inserted" ]; do
 	X2GO_PORT=$(($X2GO_PORT + 1))
 	X2GO_PORT=`echo "for(\\$i=$X2GO_PORT;\\$br ne \"true\";\\$i++){ if(\"$USED_DISPLAYS\" =~ m/\\|\\$i\\|/){\\$br=\"false\";}else{\\$br=\"true\";print \\$i;}}"|perl`
-	
+
 	#Test if the session is already in use. nxagent uses 6000+DISPLAY to open a port. Therefore this must be tested, too.
 	NX_PORT=$(($X2GO_PORT + 6000))
 	if  [ -e "/tmp/.X${X2GO_PORT}-lock" ] ||
 		[ -e "/tmp/.X11-unix/X${X2GO_PORT}" ] || 
-		grep -q "|${NX_PORT}|" <<<$USED_PORTS ; then
+		grep -q "|${NX_PORT}|" <<<$USED_NONSSH_PORTS ; then
 		OUTPUT="XXX"
 	else
 		SESSION_NAME="${USER}-${X2GO_PORT}-`date +\"%s\"`"
@@ -164,6 +163,7 @@ done
 
 while [ "$GR_PORT" == "" ] || [ "$SOUND_PORT" == "" ] || [ "$FS_PORT" == "" ]; do
 	OUTPUT=""
+	USED_PORTS=`echo -e "$(\"$X2GO_LIB_PATH/x2gogetports\" \"$HOSTNAME\")\n$USED_NONSSH_PORTS"`
 	while [ "$OUTPUT"  != "inserted" ]; do
 		SSH_PORT=$(($SSH_PORT + 1))

---

From: Moritz Struebe <[email-masked]>
Date: Tue, 16 Apr 2013 09:14:38 +0200

On 2013-04-15 23:08, Mike Gabriel wrote:
> typical class room situation) do not interfere with each other. 

I don't know how you come to the 3x conclusion, but looking at the code
I'd suggest that USED_NONSSH_PORTS as well as USED_PORTS either be
turned into a function or get updated within the while-loop. That should
reduce the amount of failures.

> This probably has to happen in x2goresume-session, as well. 

Considering the amount of perl  and code duplication we should consider
putting that into a function and sourcing it or rewriting the whole
thing in perl. Unfortunately currently time is very scarce for me.

Morty

-- 
Dipl.-Ing. Moritz 'Morty' Struebe (Wissenschaftlicher Mitarbeiter)
Lehrstuhl für Informatik 4 (Verteilte Systeme und Betriebssysteme)
Friedrich-Alexander-Universität Erlangen-Nürnberg
Martensstr. 1
91058 Erlangen

Tel   : +49 9131 85-25419
Fax   : +49 9131 85-28732
eMail : [email-masked]
WWW   : http://www4.informatik.uni-erlangen.de/~morty