Subject: New API call for nxcom (nx-libs) NXTransCleanupForReconnect

From: Nito Martinez <[email-masked]>
Date: Fri, 08 May 2015 00:40:24 +0200

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
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();

---

From: Mike Gabriel <[email-masked]>
Date: Fri, 08 May 2015 10:07:29 +0000

Hi Nito,

On  Fr 08 Mai 2015 00:40:24 CEST, Nito Martinez wrote:

> 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.
>

This is a nice patch! Please also provide a PR on Github against 3.6.x  
branch on https://github.com/ArcticaProject/nx-libs for this patch.

I will then merge it and recommend it for backporting to 3.5.0.x.

This feature is actually a very cool thing for the Arctica redesign of  
remote desktop computing via NX.

Question: have you tested connection setup changes (speed, compression  
algo, etc.) in connection with NXTransCleanupForReconnect? As I  
understand your patch, it should well facilitate roaming between  
networks (switching from cable to Wifi to GSM and stuff like that),  
right?

Mike
-- 

DAS-NETZWERKTEAM
mike gabriel, herweg 7, 24357 fleckeby
fon: +49 (1520) 1976 148

GnuPG Key ID 0x25771B31
mail: [email-masked], http://das-netzwerkteam.de

freeBusy:
https://mail.das-netzwerkteam.de/freebusy/m.gabriel%40das-netzwerkteam.de.xfb

---

From: Mike Gabriel <[email-masked]>
Date: Mon, 29 Feb 2016 07:24:14 +0000

Control: tags -1 fixed-upstream
Control: fixed -1 3.5.99.0
Control: forwarded -1 https://github.com/ArcticaProject/nx-libs/pull/25

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

This patch has been applied to 3.6.x branch of nx-libs a while ago...
https://github.com/ArcticaProject/nx-libs/pull/25

Backporting to 3.5.x is optional, not especially recommended here. As  
we plan to release nx-libs 3.6.x in June 2016, I reckon that backport  
this patch is not release critical for TheQVD.

@Nito, if it is, please give feedback. Thanks.

Mike
-- 

DAS-NETZWERKTEAM

GnuPG Key ID 0x25771B31

freeBusy:
https://mail.das-netzwerkteam.de/mailxchange/kronolith/fb.php?u=m.gabriel%40das-netzwerkteam.de