[X2Go-Commits] x2goserver.git - master (branch) updated: 3.1.1.3-167-g6634b0e

X2Go dev team git-admin at x2go.org
Thu Jun 6 01:44:20 CEST 2013


The branch, master has been updated
       via  6634b0e94f86673b9ecbd2281597e5335fd91b91 (commit)
      from  dd176a90d04b64ea0a49ccad52f5ca0b72d25673 (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 -----------------------------------------------------------------
commit 6634b0e94f86673b9ecbd2281597e5335fd91b91
Author: Mike Gabriel <mike.gabriel at das-netzwerkteam.de>
Date:   Thu Jun 6 01:43:34 2013 +0200

    Send SIGKILL to blocked X-Server (x2goagent) processes, if they do not disappear within 20secs. (Fixes: #32).

-----------------------------------------------------------------------

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 48c8bd3..304a871 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -60,6 +60,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 0780ac5..1d29bad 100755
--- a/x2goserver/lib/x2golistsessions_sql
+++ b/x2goserver/lib/x2golistsessions_sql
@@ -30,6 +30,20 @@ openlog($0,'cons,pid','user');
 setlogmask( LOG_UPTO(loglevel()) );
 
 
+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")
@@ -44,7 +58,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 710c0e2..604e6c1 100755
--- a/x2goserver/sbin/x2gocleansessions
+++ b/x2goserver/sbin/x2gocleansessions
@@ -116,18 +116,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