[X2Go-Commits] [nx-libs] 01/40: This patch allows to cleanup the nxcomp resources to allow for a second connection inside the same process, instead of a new process as is the nxproxy case.

git-admin at x2go.org git-admin at x2go.org
Sat Jun 20 00:03:18 CEST 2015


This is an automated email from the git hooks/post-receive script.

x2go pushed a commit to branch 3.6.x
in repository nx-libs.

commit 4fefe352c9d93b0a51ed2e7c34f47a0d951413db
Author: Nito Martinez <Nito at Qindel.ES>
Date:   Fri May 15 15:20:52 2015 +0200

    This patch allows to cleanup the nxcomp resources to allow for a second connection inside the same process, instead of a new process as is the nxproxy case.
    
    This involves creating a new API call
    
    void NXTransCleanupForReconnect(void);
    
    which basically cleans up the global state for the connection but does not exit the process.
    
    Background
    ==========
    This is needed for the IOS platform, where the nxproxy model of forking does not work.
    Also NX handles most of the errors with an "exit" call which in IOS cannot be easily handled.
---
 nxcomp/Loop.cpp |   27 +++++++++++++++++++++++++++
 nxcomp/Misc.h   |    1 +
 nxcomp/NX.h     |    8 ++++++++
 3 files changed, 36 insertions(+)

diff --git a/nxcomp/Loop.cpp b/nxcomp/Loop.cpp
index 7bc154f..f25aed3 100644
--- a/nxcomp/Loop.cpp
+++ b/nxcomp/Loop.cpp
@@ -1311,6 +1311,11 @@ void NXTransCleanup()
   HandleCleanup();
 }
 
+void NXTransCleanupForReconnect()
+{
+  HandleCleanupForReconnect();
+}
+
 //
 // Check the parameters for subsequent
 // initialization of the NX transport.
@@ -4873,6 +4878,28 @@ int StartKeeper()
   return 1;
 }
 
+void HandleCleanupForReconnect()
+{
+  #ifdef TEST
+  *logofs << "Loop: Going to clean up system resources for Reconnect "
+          << "in process '" << getpid() << "'.\n"
+          << logofs_flush;
+  #endif
+  handleTerminatedInLoop();
+  DisableSignals();
+  if (control)
+    CleanupChildren();
+  CleanupListeners();
+  CleanupSockets();
+  CleanupKeeper();
+  CleanupStreams();
+  CleanupLocal();
+  CleanupGlobal();
+  RestoreSignals();
+  ServerCache::lastInitReply.set(0,NULL);
+  ServerCache::lastKeymap.set(0,NULL);
+  ServerCache::getKeyboardMappingLastMap.set(0,NULL);
+}
 void HandleCleanup(int code)
 {
   #ifdef TEST
diff --git a/nxcomp/Misc.h b/nxcomp/Misc.h
index 21a5030..0cc3969 100644
--- a/nxcomp/Misc.h
+++ b/nxcomp/Misc.h
@@ -140,6 +140,7 @@ void HandleShutdown() __attribute__((noreturn));
 extern "C"
 {
   void HandleCleanup(int code = 0) __attribute__((noreturn));
+  void HandleCleanupForReconnect();
 }
 
 //
diff --git a/nxcomp/NX.h b/nxcomp/NX.h
index 2dbf686..0e4734e 100644
--- a/nxcomp/NX.h
+++ b/nxcomp/NX.h
@@ -442,6 +442,14 @@ extern int NXTransParseEnvironment(const char *env, int force);
 
 extern void NXTransCleanup(void) __attribute__((noreturn));
 
+/*
+ * Cleans up the global and local state
+ * (the same way as NXTransCleanup does)
+ * but does not exit the process
+ * Needed for IOS platform
+ */
+extern void NXTransCleanupForReconnect(void);
+
 extern const char* NXVersion();
 extern int NXMajorVersion();
 extern int NXMinorVersion();

--
Alioth's /srv/git/code.x2go.org/nx-libs.git//..//_hooks_/post-receive-email on /srv/git/code.x2go.org/nx-libs.git


More information about the x2go-commits mailing list