[X2Go-Commits] nx-libs.git - build-main (branch) updated: nxcomp/3.2.0-6

X2Go dev team git-admin at x2go.org
Fri Aug 30 16:22:16 CEST 2013


The branch, build-main has been updated
       via  92239dafb601d2ee5da1554d19631267c81fe57c (commit)
      from  d7a8d67d760a80962821f6951caee5a9c807f5be (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:
 nxcomp/Auth.cpp          |    8 +++
 nxcomp/Auth.h            |    7 ++
 nxcomp/CHANGELOG         |   34 +++++++++-
 nxcomp/Children.cpp      |   69 ++++++++++++++++++++
 nxcomp/ClientChannel.cpp |   14 +++-
 nxcomp/Control.cpp       |   61 ++++++++++++------
 nxcomp/Control.h         |    6 ++
 nxcomp/Loop.cpp          |  159 +++++++++++++++++++++++++++++++++++++++++++++-
 nxcomp/ServerChannel.cpp |   14 +++-
 nxcomp/Statistics.cpp    |    4 +-
 nxcomp/Timestamp.h       |   63 +++---------------
 nxcomp/VERSION           |    2 +-
 12 files changed, 355 insertions(+), 86 deletions(-)

The diff of changes is:
diff --git a/nxcomp/Auth.cpp b/nxcomp/Auth.cpp
index 57e2070..78f93a0 100755
--- a/nxcomp/Auth.cpp
+++ b/nxcomp/Auth.cpp
@@ -55,6 +55,8 @@ Auth::Auth(char *display, char *cookie)
 
   dataSize_ = 0;
 
+  generatedCookie_ = 0;
+
   if (display == NULL || *display == '\0' || cookie == NULL ||
           *cookie == '\0' || strlen(cookie) != 32)
   {
@@ -316,16 +318,20 @@ int Auth::getCookie()
             << "auth command.\n" << logofs_flush;
     #endif
 
+    #ifdef TEST
     cerr << "Warning" << ": Failed to read data from the X "
          << "auth command.\n";
+    #endif
 
     #ifdef PANIC
     *logofs << "Auth: WARNING! Generating a fake cookie for "
             << "X authentication.\n" << logofs_flush;
     #endif
 
+    #ifdef TEST
     cerr << "Warning" << ": Generating a fake cookie for "
          << "X authentication.\n";
+    #endif
 
     generateCookie(realCookie_);
   }
@@ -621,6 +627,8 @@ void Auth::generateCookie(char *cookie)
     data >>= 8;
   }
 
+  generatedCookie_ = 1;
+
   #ifdef TEST
   *logofs << "Auth: Generated X cookie string '"
           << cookie << "'.\n" << logofs_flush;
diff --git a/nxcomp/Auth.h b/nxcomp/Auth.h
index c8e960b..1b77aaa 100755
--- a/nxcomp/Auth.h
+++ b/nxcomp/Auth.h
@@ -52,6 +52,11 @@ class Auth
                         realData_ != NULL && dataSize_ != 0);
   }
 
+  int isFake() const
+  {
+    return generatedCookie_;
+  }
+
   //
   // Method called in the channel class to find if the
   // provided cookie matches the fake one. If the data
@@ -107,6 +112,8 @@ class Auth
   char *realData_;
 
   int dataSize_;
+
+  int generatedCookie_;
 };
 
 #endif /* Auth_H */
diff --git a/nxcomp/CHANGELOG b/nxcomp/CHANGELOG
index 12b77e5..cceeb07 100755
--- a/nxcomp/CHANGELOG
+++ b/nxcomp/CHANGELOG
@@ -1,5 +1,35 @@
 ChangeLog:
 
+nxcomp-3.2.0-6
+
+- Changes considering that unsetenv() returns void on Mac OS X.
+
+nxcomp-3.2.0-5
+
+- Fixed TR03F02024. Assume the launchd unix socket as X socket.
+
+- Changed the authorization cookie retrieval when using the launchd
+  socket on MacOSX, in order to wait for the X server start.
+
+nxcomp-3.2.0-4
+
+- Fixed TR03F02026. Unset environment variable LD_LIBRARY_PATH before
+  calling the exec function running nxclient.
+
+nxcomp-3.2.0-3
+
+- Fix addMsTimestamp() and subMsTimestamp(). Remove the check for
+  a valid input in diffTimestamp() and diffUsTimestamp().
+
+nxcomp-3.2.0-2
+
+- Fixed TR12E01973. Now the correct number of bits are used for the
+  number of points in a X_FillPoly request.
+
+nxcomp-3.2.0-1
+
+- Opened the 3.2.0 branch based on nxcomp-3.1.0-6.
+
 nxcomp-3.1.0-6
 
 - Always use a timeout of 50 ms to update the congestion counter.
@@ -36,7 +66,7 @@ nxcomp-3.1.0-2
   
 nxcomp-3.1.0-1
 
-- Opened the 3.0.1 branch based on nxcomp-3.0.0-46.
+- Opened the 3.1.0 branch based on nxcomp-3.0.0-46.
 
 nxcomp-3.0.0-46
 
@@ -325,7 +355,7 @@ nxcomp-3.0.0-15
 
 - Removed the pending_ flag from the proxy and channel class mem-
   bers. If needed, the classes will query the transport buffers
-  to see whether there is data pending.B
+  to see whether there is data pending.
 
 - Removed the additional parameter from NXTransFlush().
 
diff --git a/nxcomp/Children.cpp b/nxcomp/Children.cpp
index c9b4b96..ec4ce35 100755
--- a/nxcomp/Children.cpp
+++ b/nxcomp/Children.cpp
@@ -71,6 +71,10 @@ extern char *GetClientPath();
 
 extern int CheckParent(char *name, char *type, int parent);
 
+#ifdef __sun
+extern char **environ;
+#endif
+
 //
 // Close all the unused descriptors and
 // install any signal handler that might
@@ -86,6 +90,12 @@ static void SystemCleanup(char *name);
 static void MemoryCleanup(char *name);
 
 //
+// Remove 'name' from the environment.
+//
+
+static int UnsetEnv(char *name);
+
+//
 // Start a nxclient process in dialog mode.
 //
 
@@ -187,6 +197,8 @@ int NXTransDialog(const char *caption, const char *message,
 
   parent[DEFAULT_STRING_LIMIT - 1] = '\0';
 
+  UnsetEnv("LD_LIBRARY_PATH");
+
   for (int i = 0; i < 2; i++)
   {
     if (local != 0)
@@ -409,6 +421,8 @@ int NXTransClient(const char* display)
 
   #endif
 
+  UnsetEnv("LD_LIBRARY_PATH");
+
   for (int i = 0; i < 2; i++)
   {
     execlp(command, command, NULL);
@@ -962,3 +976,58 @@ void MemoryCleanup(char *name)
 
   EnableSignals();
 }
+
+int UnsetEnv(char *name)
+{
+  int result;
+
+  #ifdef __sun
+
+  char **pEnv = environ;
+
+  int nameLen = strlen(name) + 1;
+
+  char *varName = new char[nameLen + 1];
+
+  strcpy(varName, name);
+
+  strcat(varName, "=");
+
+  pEnv = environ;
+
+  while (*pEnv != NULL)
+  {
+    if (!strncmp(varName, *pEnv, nameLen))
+    {
+      break;
+    }
+
+    *pEnv++;
+  }
+
+  while (*pEnv != NULL)
+  {
+    *pEnv = *(pEnv + 1);
+
+    pEnv++;
+  }
+
+  result = 0;
+
+  #else
+
+  #ifdef __APPLE__
+
+  unsetenv(name);
+  result = 0;
+
+  #else
+
+  result = unsetenv(name);
+
+  #endif
+
+  #endif
+
+  return result;
+}
diff --git a/nxcomp/ClientChannel.cpp b/nxcomp/ClientChannel.cpp
index 3c45501..e69a879 100755
--- a/nxcomp/ClientChannel.cpp
+++ b/nxcomp/ClientChannel.cpp
@@ -1139,8 +1139,18 @@ int ClientChannel::handleRead(EncodeBuffer &encodeBuffer, const unsigned char *m
           }
 
           unsigned int numPoints = ((inputLength - 16) >> 2);
-          encodeBuffer.encodeCachedValue(numPoints, 14,
-                             clientCache_ -> fillPolyNumPointsCache, 4);
+
+          if (control -> isProtoStep10() == 1)
+          {
+            encodeBuffer.encodeCachedValue(numPoints, 16,
+                               clientCache_ -> fillPolyNumPointsCache, 4);
+          }
+          else
+          {
+            encodeBuffer.encodeCachedValue(numPoints, 14,
+                               clientCache_ -> fillPolyNumPointsCache, 4);
+          }
+
           encodeBuffer.encodeXidValue(GetULONG(inputMessage + 4, bigEndian_),
                              clientCache_ -> drawableCache);
           encodeBuffer.encodeXidValue(GetULONG(inputMessage + 8, bigEndian_),
diff --git a/nxcomp/Control.cpp b/nxcomp/Control.cpp
index e6693d4..19105be 100755
--- a/nxcomp/Control.cpp
+++ b/nxcomp/Control.cpp
@@ -659,10 +659,11 @@ Control::Control()
   // time the session is negotiated.
   //
 
-  protoStep6_ = 0;
-  protoStep7_ = 0;
-  protoStep8_ = 0;
-  protoStep9_ = 0;
+  protoStep6_  = 0;
+  protoStep7_  = 0;
+  protoStep8_  = 0;
+  protoStep9_  = 0;
+  protoStep10_ = 0;
 }
 
 Control::~Control()
@@ -734,37 +735,51 @@ void Control::setProtoStep(int step)
   {
     case 6:
     {
-      protoStep6_ = 1;
-      protoStep7_ = 0;
-      protoStep8_ = 0;
-      protoStep9_ = 0;
+      protoStep6_  = 1;
+      protoStep7_  = 0;
+      protoStep8_  = 0;
+      protoStep9_  = 0;
+      protoStep10_ = 0;
 
       break;
     }
     case 7:
     {
-      protoStep6_ = 1;
-      protoStep7_ = 1;
-      protoStep8_ = 0;
-      protoStep9_ = 0;
+      protoStep6_  = 1;
+      protoStep7_  = 1;
+      protoStep8_  = 0;
+      protoStep9_  = 0;
+      protoStep10_ = 0;
 
       break;
     }
     case 8:
     {
-      protoStep6_ = 1;
-      protoStep7_ = 1;
-      protoStep8_ = 1;
-      protoStep9_ = 0;
+      protoStep6_  = 1;
+      protoStep7_  = 1;
+      protoStep8_  = 1;
+      protoStep9_  = 0;
+      protoStep10_ = 0;
 
       break;
     }
     case 9:
     {
-      protoStep6_ = 1;
-      protoStep7_ = 1;
-      protoStep8_ = 1;
-      protoStep9_ = 1;
+      protoStep6_  = 1;
+      protoStep7_  = 1;
+      protoStep8_  = 1;
+      protoStep9_  = 1;
+      protoStep10_ = 0;
+
+      break;
+    }
+    case 10:
+    {
+      protoStep6_  = 1;
+      protoStep7_  = 1;
+      protoStep8_  = 1;
+      protoStep9_  = 1;
+      protoStep10_ = 1;
 
       break;
     }
@@ -783,7 +798,11 @@ void Control::setProtoStep(int step)
 
 int Control::getProtoStep()
 {
-  if (protoStep9_ == 1)
+  if (protoStep10_ == 1)
+  {
+    return 10;
+  }
+  else if (protoStep9_ == 1)
   {
     return 9;
   }
diff --git a/nxcomp/Control.h b/nxcomp/Control.h
index 9d998a3..9750b4c 100755
--- a/nxcomp/Control.h
+++ b/nxcomp/Control.h
@@ -719,6 +719,11 @@ class Control
     return protoStep9_;
   }
 
+  int isProtoStep10()
+  {
+    return protoStep10_;
+  }
+
   private:
 
   //
@@ -736,6 +741,7 @@ class Control
   int protoStep7_;
   int protoStep8_;
   int protoStep9_;
+  int protoStep10_;
 };
 
 #endif /* Control_H */
diff --git a/nxcomp/Loop.cpp b/nxcomp/Loop.cpp
index 0a5b3a2..9992a77 100755
--- a/nxcomp/Loop.cpp
+++ b/nxcomp/Loop.cpp
@@ -888,6 +888,13 @@ static int useSlaveSocket = 0;
 static int useAgentSocket = 0;
 
 //
+// Set if the launchd service is running
+// and its socket must be used as X socket.
+//
+
+static int useLaunchdSocket = 0;
+
+//
 // Set by user if he/she wants to modify
 // the default TCP_NODELAY option as set
 // in control.
@@ -3745,7 +3752,90 @@ int SetupAuthInstance()
   {
     if (authCookie != NULL && *authCookie != '\0')
     {
-      auth = new Auth(displayHost, authCookie);
+      if (useLaunchdSocket == 1)
+      {
+        //
+        // If we are going to retrieve the X11 autho-
+        // rization through the launchd service, make
+        // a connection to its socket to trigger the
+        // X server starting.
+        //
+
+        sockaddr_un launchdAddrUnix;
+
+        unsigned int launchdAddrLength = sizeof(sockaddr_un);
+
+        int launchdAddrFamily = AF_UNIX;
+
+        launchdAddrUnix.sun_family = AF_UNIX;
+
+        const int launchdAddrNameLength = 108;
+
+        int success = -1;
+
+        strncpy(launchdAddrUnix.sun_path, displayHost, launchdAddrNameLength);
+
+        *(launchdAddrUnix.sun_path + launchdAddrNameLength - 1) = '\0';
+
+        #ifdef TEST
+        *logofs << "Loop: Connecting to launchd service "
+                << "on Unix port '" << displayHost << "'.\n" << logofs_flush;
+        #endif
+
+        int launchdFd = socket(launchdAddrFamily, SOCK_STREAM, PF_UNSPEC);
+
+        if (launchdFd < 0)
+        {
+          #ifdef PANIC
+          *logofs << "Loop: PANIC! Call to socket failed. "
+                  << "Error is " << EGET() << " '" << ESTR()
+                  << "'.\n" << logofs_flush;
+          #endif
+        }
+        else if ((success = connect(launchdFd, (sockaddr *) &launchdAddrUnix, launchdAddrLength)) < 0)
+        {
+          #ifdef WARNING
+          *logofs << "Loop: WARNING! Connection to launchd service "
+                  << "on Unix port '" << displayHost << "' failed "
+                  << "with error " << EGET() << ", '" << ESTR() << "'.\n"
+                  << logofs_flush;
+          #endif
+        }
+
+        if (launchdFd >= 0)
+        {
+          close(launchdFd);
+        }
+
+        //
+        // The real cookie will not be available
+        // until the X server starts. Query for the
+        // cookie in a loop, unless the connection
+        // to the launchd service failed.
+        //
+
+        int attempts = (success < 0 ? 1 : 10);
+
+        for (int i = 0; i < attempts; i++)
+        {
+          delete auth;
+
+          auth = new Auth(displayHost, authCookie);
+
+          if (auth != NULL && auth -> isFake() == 1)
+          {
+            usleep(200000);
+
+            continue;
+          }
+
+          break;
+        }
+      }
+      else
+      {
+        auth = new Auth(displayHost, authCookie);
+      }
 
       if (auth == NULL || auth -> isValid() != 1)
       {
@@ -3758,6 +3848,20 @@ int SetupAuthInstance()
 
         HandleCleanup();
       }
+      else if (auth -> isFake() == 1)
+      {
+        #ifdef WARNING
+        *logofs << "Loop: WARNING! Could not retrieve the X server "
+                << "authentication cookie.\n"
+                << logofs_flush;
+        #endif
+
+        cerr << "Warning" << ": Failed to read data from the X "
+             << "auth command.\n";
+
+        cerr << "Warning" << ": Generated a fake cookie for X "
+             << "authentication.\n";
+      }
     }
     else
     {
@@ -4068,6 +4172,20 @@ int SetupDisplaySocket(int &xServerAddrFamily, sockaddr *&xServerAddr,
 
   strcpy(display, displayHost);
 
+  #ifdef __APPLE__
+
+  if (strncasecmp(display, "/tmp/launch", 11) == 0)
+  {
+    #ifdef TEST
+    *logofs << "Loop: Using launchd service on socket '"
+            << display << "'.\n" << logofs_flush;
+    #endif
+
+    useLaunchdSocket = 1;
+  }
+
+  #endif
+
   char *separator = rindex(display, ':');
 
   if ((separator == NULL) || !isdigit(*(separator + 1)))
@@ -4092,7 +4210,16 @@ int SetupDisplaySocket(int &xServerAddrFamily, sockaddr *&xServerAddr,
           << xPort << "'.\n" << logofs_flush;
   #endif
 
+  #ifdef __APPLE__
+
+  if (separator == display || strcmp(display, "unix") == 0 ||
+          useLaunchdSocket == 1)
+
+  #else
+
   if (separator == display || strcmp(display, "unix") == 0)
+
+  #endif
   {
     //
     // UNIX domain port.
@@ -4129,6 +4256,15 @@ int SetupDisplaySocket(int &xServerAddrFamily, sockaddr *&xServerAddr,
     snprintf(unixSocketDir, DEFAULT_STRING_LENGTH - 1, "%s/.X11-unix",
                  control -> TempPath);
 
+    #ifdef __APPLE__
+
+    if (useLaunchdSocket == 1)
+    {
+      snprintf(unixSocketDir, DEFAULT_STRING_LENGTH - 1, "%s", display);
+    }
+
+    #endif
+
     *(unixSocketDir + DEFAULT_STRING_LENGTH - 1) = '\0';
 
     #ifdef TEST
@@ -4160,6 +4296,15 @@ int SetupDisplaySocket(int &xServerAddrFamily, sockaddr *&xServerAddr,
 
     sprintf(unixSocketName, "%s/X%d", unixSocketDir, xPort);
 
+    #ifdef __APPLE__
+
+    if (useLaunchdSocket == 1)
+    {
+      sprintf(unixSocketName, "%s:%d", unixSocketDir, xPort);
+    }
+
+    #endif
+
     #ifdef TEST
     *logofs << "Loop: Assuming X socket name '" << unixSocketName
             << "'.\n" << logofs_flush;
@@ -12345,9 +12490,13 @@ int SetVersion()
   {
     step = 7;
   }
-  else if (major >= 3)
+  else if (major == 3)
   {
-    if (minor > 0 || patch > 0)
+    if (minor >= 2)
+    {
+      step = 10;
+    }
+    else if (minor > 0 || patch > 0)
     {
       step = 9;
     }
@@ -12356,6 +12505,10 @@ int SetVersion()
       step = 8;
     }
   }
+  else if (major > 3)
+  {
+    step = 10;
+  }
 
   if (step == 0)
   {
diff --git a/nxcomp/ServerChannel.cpp b/nxcomp/ServerChannel.cpp
index ba731c5..8df4bad 100755
--- a/nxcomp/ServerChannel.cpp
+++ b/nxcomp/ServerChannel.cpp
@@ -2753,8 +2753,18 @@ int ServerChannel::handleWrite(const unsigned char *message, unsigned int length
           }
 
           unsigned int numPoints;
-          decodeBuffer.decodeCachedValue(numPoints, 14,
-                                 clientCache_ -> fillPolyNumPointsCache, 4);
+
+          if (control -> isProtoStep10() == 1)
+          {
+            decodeBuffer.decodeCachedValue(numPoints, 16,
+                               clientCache_ -> fillPolyNumPointsCache, 4);
+          }
+          else
+          {
+            decodeBuffer.decodeCachedValue(numPoints, 14,
+                               clientCache_ -> fillPolyNumPointsCache, 4);
+          }
+
           outputLength = 16 + (numPoints << 2);
           outputMessage = writeBuffer_.addMessage(outputLength);
           decodeBuffer.decodeXidValue(value, clientCache_ -> drawableCache);
diff --git a/nxcomp/Statistics.cpp b/nxcomp/Statistics.cpp
index 8b57921..b70dd2e 100755
--- a/nxcomp/Statistics.cpp
+++ b/nxcomp/Statistics.cpp
@@ -410,14 +410,14 @@ void Statistics::updateBitrate(int bytes)
 
     if (diffStartInMs > control -> ShortBitrateTimeFrame)
     {
-      addMsToTimestamp(startShortFrameTs_, diffStartInMs);
+      addMsTimestamp(startShortFrameTs_, diffStartInMs);
     }
 
     diffStartInMs = diffTimestamp(thisFrameTs, startLongFrameTs_);
 
     if (diffStartInMs > control -> LongBitrateTimeFrame)
     {
-      addMsToTimestamp(startLongFrameTs_, diffStartInMs);
+      addMsTimestamp(startLongFrameTs_, diffStartInMs);
     }
 
     startFrameTs_ = thisFrameTs;
diff --git a/nxcomp/Timestamp.h b/nxcomp/Timestamp.h
index 270dd38..15246dd 100755
--- a/nxcomp/Timestamp.h
+++ b/nxcomp/Timestamp.h
@@ -87,20 +87,13 @@ inline T_timestamp getTimestamp(long ms)
 
 inline long diffTimestamp(const T_timestamp &ts1, const T_timestamp &ts2)
 {
-  if (ts1.tv_sec == 0 && ts1.tv_usec == 0)
-  {
-     return -1;
-  }
-
   //
   // Add 500 microseconds to round up
   // to the nearest millisecond.
   //
 
-  long ms = ((ts2.tv_sec * 1000 + (ts2.tv_usec + 500) / 1000) -
-                 (ts1.tv_sec * 1000 + (ts1.tv_usec + 500) / 1000));
-
-  return (ms < 0 ? -1 : ms);
+  return ((ts2.tv_sec * 1000 + (ts2.tv_usec + 500) / 1000) -
+             (ts1.tv_sec * 1000 + (ts1.tv_usec + 500) / 1000));
 }
 
 //
@@ -110,20 +103,8 @@ inline long diffTimestamp(const T_timestamp &ts1, const T_timestamp &ts2)
 
 inline long diffUsTimestamp(const T_timestamp &ts1, const T_timestamp &ts2)
 {
-  if (ts1.tv_sec == 0 && ts1.tv_usec == 0)
-  {
-     return -1;
-  }
-
-  //
-  // Add 500 microseconds to round up
-  // to the nearest millisecond.
-  //
-
-  long ms = ((ts2.tv_sec * 1000000 + ts2.tv_usec) -
-                 (ts1.tv_sec * 1000000 + ts1.tv_usec));
-
-  return (ms < 0 ? -1 : ms);
+  return ((ts2.tv_sec * 1000000 + ts2.tv_usec) -
+             (ts1.tv_sec * 1000000 + ts1.tv_usec));
 }
 
 //
@@ -234,40 +215,16 @@ inline bool isTimestamp(const T_timestamp &ts)
   return 1;
 }
 
-inline void subMsToTimestamp(T_timestamp &ts, long ms)
+inline void subMsTimestamp(T_timestamp &ts, long ms)
 {
-  long sec = ms / 1000;
-
-  ts.tv_sec -= sec;
-
-  long mod = ms % (ms * 1000);
-
-  if (ts.tv_usec >= (mod * 1000))
-  {
-    ts.tv_sec -= mod * 1000;
-  }
-  else
-  {
-    ts.tv_sec--;
-
-    ts.tv_usec = 1000000 - mod * 1000;
-  }
+  ts.tv_sec  -= ms / 1000;
+  ts.tv_usec -= (ms % 1000) * 1000;
 }
 
-inline void addMsToTimestamp(T_timestamp &ts, long ms)
+inline void addMsTimestamp(T_timestamp &ts, long ms)
 {
-  long sec = ms / 1000;
-
-  ts.tv_sec += sec;
-
-  long mod = ms % (ms * 1000);
-
-  ts.tv_usec += mod * 1000;
-
-  if (ts.tv_usec > 1000000)
-  {
-    ts.tv_sec += 1;
-  }
+  ts.tv_sec  += ms / 1000;
+  ts.tv_usec += (ms % 1000) * 1000;
 }
 
 //
diff --git a/nxcomp/VERSION b/nxcomp/VERSION
index fd2a018..944880f 100755
--- a/nxcomp/VERSION
+++ b/nxcomp/VERSION
@@ -1 +1 @@
-3.1.0
+3.2.0


hooks/post-receive
-- 
nx-libs.git (NX (redistributed))

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 "nx-libs.git" (NX (redistributed)).




More information about the x2go-commits mailing list