From Nito@Qindel.ES  Fri May  8 00:40:26 2015
Received: (at submit) by bugs.x2go.org; 7 May 2015 22:40:29 +0000
X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on
	ymir.das-netzwerkteam.de
X-Spam-Level: 
X-Spam-Status: No, score=0.0 required=5.0 tests=BAYES_40,HTML_MESSAGE
	autolearn=ham version=3.3.2
X-Greylist: delayed 314 seconds by postgrey-1.34 at ymir.das-netzwerkteam.de; Fri, 08 May 2015 00:40:26 CEST
Received: from thor.qindel.com (smtp.qindel.com [89.140.90.34])
	by ymir.das-netzwerkteam.de (Postfix) with ESMTP id 13E515DA80
	for <submit@bugs.x2go.org>; Fri,  8 May 2015 00:40:25 +0200 (CEST)
Received: from localhost (localhost [127.0.0.1])
	by thor.qindel.com (Postfix) with ESMTP id E32DD6020E
	for <submit@bugs.x2go.org>; Fri,  8 May 2015 00:40:25 +0200 (CEST)
Received: from thor.qindel.com ([127.0.0.1])
	by localhost (thor.qindel.com [127.0.0.1]) (amavisd-new, port 10032)
	with ESMTP id 0ISONZYdD4dh for <submit@bugs.x2go.org>;
	Fri,  8 May 2015 00:40:25 +0200 (CEST)
Received: from localhost (localhost [127.0.0.1])
	by thor.qindel.com (Postfix) with ESMTP id 670396020F
	for <submit@bugs.x2go.org>; Fri,  8 May 2015 00:40:25 +0200 (CEST)
X-Virus-Scanned: amavisd-new at thor.qindel.com
Received: from thor.qindel.com ([127.0.0.1])
	by localhost (thor.qindel.com [127.0.0.1]) (amavisd-new, port 10026)
	with ESMTP id 2_wXD9cFoqyO for <submit@bugs.x2go.org>;
	Fri,  8 May 2015 00:40:25 +0200 (CEST)
Received: from [10.1.0.254] (qvd-254.int.qindel.com [172.26.11.254])
	by thor.qindel.com (Postfix) with ESMTPSA id 2D0606020E
	for <submit@bugs.x2go.org>; Fri,  8 May 2015 00:40:25 +0200 (CEST)
Message-ID: <554BE9D8.8080007@Qindel.ES>
Date: Fri, 08 May 2015 00:40:24 +0200
From: Nito Martinez <Nito@Qindel.ES>
User-Agent: Mozilla/5.0 (X11; Linux i686 on x86_64; rv:17.0) Gecko/20130801 Thunderbird/17.0.8
MIME-Version: 1.0
To: submit@bugs.x2go.org
Subject: New API call for nxcom (nx-libs) NXTransCleanupForReconnect
Content-Type: multipart/mixed;
 boundary="------------030507060506090903000205"

This is a multi-part message in MIME format.
--------------030507060506090903000205
Content-Type: multipart/alternative;
 boundary="------------030509030903080302010206"


--------------030509030903080302010206
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit

Package: nx-libs
Version: 3.5.0.28

Description:

The following patch includes support for a new API call 
NXTransCleanupForReconnect, which basically clears the state of nxcomp 
proxy side (modified nxproxy), so that a reconnection is possible.

Rationale:

Usually nxproxy clears the status of the connection by doing an exit and 
launching a new nxproxy. This strategy does not work for applications in 
IOS which do not allow forking.

Special care has been taking to not modify any of the other nxcomp code.

Regards,

Nito

--------------030509030903080302010206
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: 7bit

<html>
  <head>

    <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    <font face="Arial">Package: nx-libs<br>
      Version: 3.5.0.28<br>
      <br>
      Description:<br>
      <br>
      The following patch includes support for a new API call
      NXTransCleanupForReconnect, which basically clears the state of
      nxcomp proxy side (modified nxproxy), so that a reconnection is
      possible.<br>
      <br>
      Rationale:<br>
      <br>
      Usually nxproxy clears the status of the connection by doing an
      exit and launching a new nxproxy. This strategy does not work for
      applications in IOS which do not allow forking.<br>
      <br>
      Special care has been taking to not modify any of the other nxcomp
      code.<br>
      <br>
      Regards,<br>
      <br>
      Nito<br>
    </font>
  </body>
</html>

--------------030509030903080302010206--

--------------030507060506090903000205
Content-Type: text/x-diff;
 name="nxcomp-reconnect.patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
 filename="nxcomp-reconnect.patch"

diff --git a/nx-libs-3.5.0.22/nxcomp/Loop.cpp b/nx-libs-3.5.0.22/nxcomp/Loop.cpp
index 8c19467..16b757a 100644
--- a/nx-libs-3.5.0.22/nxcomp/Loop.cpp
+++ b/nx-libs-3.5.0.22/nxcomp/Loop.cpp
@@ -1311,6 +1311,11 @@ void NXTransCleanup()
   HandleCleanup();
 }

+void NXTransCleanupForReconnect()
+{
+  HandleCleanupForReconnect();
+}
+
 //
 // Check the parameters for subsequent
 // initialization of the NX transport.
@@ -4835,6 +4840,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/nx-libs-3.5.0.22/nxcomp/Misc.h b/nx-libs-3.5.0.22/nxcomp/Misc.h
index 21a5030..0cc3969 100644
--- a/nx-libs-3.5.0.22/nxcomp/Misc.h
+++ b/nx-libs-3.5.0.22/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/nx-libs-3.5.0.22/nxcomp/NX.h b/nx-libs-3.5.0.22/nxcomp/NX.h
index 2dbf686..0e4734e 100644
--- a/nx-libs-3.5.0.22/nxcomp/NX.h
+++ b/nx-libs-3.5.0.22/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();

--------------030507060506090903000205--

