Subject: Re: 25 user logon problem

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.

On Do 28 Mär 2013 16:31:23 CET Thomas Hanschke wrote:

> 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 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))