[X2Go-Commits] x2goserver.git - build-baikal (branch) updated: 4.0.0.2-8-gafeeb58

X2Go dev team git-admin at x2go.org
Fri Jun 7 23:04:11 CEST 2013


The branch, build-baikal has been updated
       via  afeeb580215270c4a1658b6773c8cb2ff6d4e2ed (commit)
      from  dfe76c81c09a38819bac236020c2b49eeaede246 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
-----------------------------------------------------------------------

Summary of changes:
 debian/changelog                    |    2 ++
 x2goserver/lib/x2golistsessions_sql |   16 +++++++++++++++-
 x2goserver/sbin/x2gocleansessions   |   29 +++++++++++++++++++++++++++--
 3 files changed, 44 insertions(+), 3 deletions(-)

The diff of changes is:
diff --git a/debian/changelog b/debian/changelog
index cadd8be..64f8ff5 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -8,6 +8,8 @@ x2goserver (4.0.0.3-0~x2go1) UNRELEASED; urgency=low
       in the session DB.
     - Add support for terminating sessions via the session DB.
     - Raise the frequency of the x2gocleansessions loop to every two seconds.
+    - Send SIGKILL to blocked X-Server (x2goagent) processes, if they do not
+      disappear within 20secs. (Fixes: #32).
 
  -- Mike Gabriel <mike.gabriel at das-netzwerkteam.de>  Sun, 19 May 2013 15:02:53 +0200
 
diff --git a/x2goserver/lib/x2golistsessions_sql b/x2goserver/lib/x2golistsessions_sql
index 2957437..b667b4f 100755
--- a/x2goserver/lib/x2golistsessions_sql
+++ b/x2goserver/lib/x2golistsessions_sql
@@ -31,6 +31,20 @@ openlog($0,'cons,pid','user');
 setlogmask( LOG_UPTO(x2gologlevel()) );
 
 
+sub check_pid
+{
+	my $pid=shift;
+	my $sess=shift;
+	open (F,"</proc/$pid/cmdline") or return 0;
+	my $text=<F>;
+	close (F);
+	if ($text =~ m/$sess/)
+	{
+		return 1;
+	}
+	return 0;
+}
+
 my $serv=shift;
 my @array;
 if($serv eq "--all-servers")
@@ -45,7 +59,7 @@ my $i;
 for ( $i=0;$i<@array;$i++) 
 {
 	my @ln=split('\|', at array[$i]);
-	if (@ln[4] eq "F")
+	if ((@ln[4] eq "F") && (check_pid(@ln[0], @ln[1]))
 	{
 		my $sid = @ln[1];
 		dbsys_rmsessionsroot($sid);
diff --git a/x2goserver/sbin/x2gocleansessions b/x2goserver/sbin/x2gocleansessions
index ca4f95a..1548e2b 100755
--- a/x2goserver/sbin/x2gocleansessions
+++ b/x2goserver/sbin/x2gocleansessions
@@ -118,18 +118,43 @@ elsif ($pid == 0 )
 	$SIG{TERM}=\&catch_term;
 	$SIG{CHLD} = sub { wait };
 
+	my %blocked_sessions = ();
+
 	while(sleep 2)
 	{
 		my $outp=`$x2go_lib_path/x2golistsessions_sql $serv 2>/dev/null`;
 		my @outp=split("\n","$outp");
+
+		# forget earlier remembered blocked sessions
+		while ( my ($session, $blocked_time) = each(%blocked_sessions) ) {
+			if (! join(',', @outp)=~m/$session/)
+			{
+				delete $blocked_sessions{$session}
+			}
+		}
+
 		for (my $i=0;$i<@outp;$i++)
 		{
 			my @sinfo=split('\\|',"@outp[$i]");
 			if (@sinfo[4]eq 'F')
 			{
+
 				syslog('debug', "@sinfo[1] is blocked");
-				syslog('debug', "@sinfo[1]: unmounting all shares");
-				system( "su @sinfo[11] -c \"export HOSTNAME && x2goumount-session @sinfo[1]\" 2> /dev/null");
+				if defined $hash{ $key }
+				{
+					$blocked_sessions{@sinfo[1]} += 2;
+					if ($blocked_sessions{@sinfo[1]} >= 20) {
+					{
+						# send SIGKILL to dangling X-server processes
+						syslog('warning', "@sinfo[1]: found stale X-server process (@sinfo[0]), sending SIGKILL");
+						qw(kill -9 @sinfo[0])
+					}
+				} else {
+					$blocked_sessions{@sinfo[1]} = 0;
+					syslog('debug', "@sinfo[1]: unmounting all shares");
+					system( "su @sinfo[11] -c \"export HOSTNAME && x2goumount-session @sinfo[1]\" 2> /dev/null");
+				}
+
 			}
 			elsif (! check_pid (@sinfo[0], at sinfo[1], at sinfo[12]))
 			{


hooks/post-receive
-- 
x2goserver.git (X2Go Server)

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "x2goserver.git" (X2Go Server).




More information about the x2go-commits mailing list