[X2Go-Commits] x2goserver.git - build-baikal (branch) updated: 3.1.0.1-22-gbdf58be

X2Go dev team git-admin at x2go.org
Wed Dec 4 06:22:05 CET 2013


The branch, build-baikal has been updated
       via  bdf58be37831c772c5f888e267e807c87d13f3d3 (commit)
      from  e9fc713660e691425c8a6729d0280aa941253c76 (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/bin/x2goresume-session                  |   13 +++++++++-
 x2goserver/lib/x2godbwrapper.pm                    |   27 +++++++++++++++++++-
 x2goserver/lib/{x2gochangestatus => x2gogetstatus} |    8 +++---
 x2goserver/lib/x2gosqlitewrapper.pl                |   21 +++++++++++++++
 5 files changed, 65 insertions(+), 6 deletions(-)
 copy x2goserver/lib/{x2gochangestatus => x2gogetstatus} (94%)

The diff of changes is:
diff --git a/debian/changelog b/debian/changelog
index 2e42dad..f8a24d5 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -13,6 +13,8 @@ x2goserver (3.1.1.0-0~x2go1) UNRELEASED; urgency=low
     - Update date and version number in man pages.
     - Add syslogging to SQLite3 session DB backend for occuring
       DB failures.
+    - If setting a session state to 'R' fails in x2goresume-session,
+      simly try again.
   * Remove /etc/x2go/applications on package removal if it is a
     symlink, keep it, if it is a directory. Remove /etc/x2go
     (if empty after purge) on package purge.
diff --git a/x2goserver/bin/x2goresume-session b/x2goserver/bin/x2goresume-session
index e03751a..baf639a 100755
--- a/x2goserver/bin/x2goresume-session
+++ b/x2goserver/bin/x2goresume-session
@@ -149,7 +149,18 @@ fi
 
 echo "$NEWOPTIONS" >"${SESSION_DIR}/options"
 
-$X2GO_LIB_PATH/x2goresume  "$X2GO_CLIENT" "$SESSION_NAME"  "$GR_PORT" "$SOUND_PORT" "$FS_PORT" > /dev/null
+# we really have to make sure the session database got this write operation
+# this may just be an SQLite issue so...
+# FIXME: probably migrate this piece of code to the SQLite db backend...
+while True; do 
+	$X2GO_LIB_PATH/x2goresume  "$X2GO_CLIENT" "$SESSION_NAME"  "$GR_PORT" "$SOUND_PORT" "$FS_PORT" > /dev/null
+	if [ $($X2GO_LIB_PATH/x2gogetstatus "$SESSION_NAME") == "R" ]; then
+		break;
+	else
+		$X2GO_LIB_PATH/x2gosyslog "$0" "warning" "failed to write to X2Go db, will try again..."
+		sleep 1;
+	fi
+done
 
 # run x2goserver-extensions for pre-resume
 x2gofeature X2GO_RUN_EXTENSIONS &>/dev/null && x2goserver-run-extensions "$SESSION_NAME" pre-resume || true
diff --git a/x2goserver/lib/x2godbwrapper.pm b/x2goserver/lib/x2godbwrapper.pm
index aec0294..2690544 100644
--- a/x2goserver/lib/x2godbwrapper.pm
+++ b/x2goserver/lib/x2godbwrapper.pm
@@ -85,7 +85,7 @@ if ($backend eq 'postgres')
 
 use base 'Exporter';
 
-our @EXPORT=('db_listsessions','db_listsessions_all', 'db_getservers', 'db_getagent', 'db_resume', 'db_changestatus', 
+our @EXPORT=('db_listsessions','db_listsessions_all', 'db_getservers', 'db_getagent', 'db_resume', 'db_changestatus', 'db_getstatus', 
              'db_getdisplays', 'db_insertsession', 'db_getports', 'db_insertport', 'db_rmport', 'db_createsession', 'db_insertmount', 
              'db_getmounts', 'db_deletemount', 'db_getdisplay', 'dbsys_getmounts', 'dbsys_listsessionsroot', 
              'dbsys_listsessionsroot_all', 'dbsys_rmsessionsroot');
@@ -410,6 +410,31 @@ sub db_changestatus
 	syslog('debug', "db_changestatus called, session ID: $sid, new status: $status");
 }
 
+sub db_getstatus
+{
+	my $sid=shift or die "argument \"session_id\" missed";
+	my $status='';
+	if ($backend eq 'postgres')
+	{
+		my $dbh=DBI->connect("dbi:Pg:dbname=$db;host=$host;port=$port;sslmode=$sslmode", "$dbuser", "$dbpass",{AutoCommit => 1}) or die $_;
+		my $sth=$dbh->prepare("select status from sessions_view where session_id = '$sid'");
+		$sth->execute($sid) or die;
+		my @data;
+		if (@data = $sth->fetchrow_array) 
+		{
+			$status=@data[0];
+		}
+		$sth->finish();
+		$dbh->disconnect();
+	}
+	if ($backend eq 'sqlite')
+	{
+		$status=`$x2go_lib_path/x2gosqlitewrapper getstatus $sid`;
+	}
+	syslog('debug', "db_getstatus called, session ID: $sid, return value: $status");
+	return $status;
+}
+
 sub db_getdisplays
 {
 	my @displays;
diff --git a/x2goserver/lib/x2gochangestatus b/x2goserver/lib/x2gogetstatus
similarity index 94%
copy from x2goserver/lib/x2gochangestatus
copy to x2goserver/lib/x2gogetstatus
index ce33520..a245352 100755
--- a/x2goserver/lib/x2gochangestatus
+++ b/x2goserver/lib/x2gogetstatus
@@ -30,11 +30,11 @@ use x2gologlevel;
 openlog($0,'cons,pid','user');
 setlogmask( LOG_UPTO(x2gologlevel()) );
 
-
-my $status=shift or die;
+my $status;
 my $sid=shift or die;
 
-db_changestatus($status, $sid);
+$status = db_getstatus($sid);
+print "$status\n";
 
 # closing syslog 
-closelog;
\ No newline at end of file
+closelog;
diff --git a/x2goserver/lib/x2gosqlitewrapper.pl b/x2goserver/lib/x2gosqlitewrapper.pl
index 4ad329e..1d8923a 100755
--- a/x2goserver/lib/x2gosqlitewrapper.pl
+++ b/x2goserver/lib/x2gosqlitewrapper.pl
@@ -270,6 +270,27 @@ elsif($cmd eq  "changestatus")
 	$sth->finish();
 }
 
+elsif($cmd eq  "getstatus")
+{
+	my $sid=shift or die "argument \"session_id\" missed";
+	check_user($sid);
+	my $sth=$dbh->prepare("select status from sessions where session_id = ?");
+	$sth->execute($sid);
+	if ($sth->err())
+	{
+		syslog('error', "changestatus (SQLite3 session db backend) failed with exitcode: $sth->err()");
+		die();
+	}
+	my @data;
+	my $status;
+	@data = $sth->fetchrow_array;
+	{
+		$status = @data[0];
+	}
+	$sth->finish();
+	print $status;
+}
+
 elsif($cmd eq  "getdisplays")
 {
 	#ignore $server


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