Branch: ulab-next

81e2e26a 2019-03-16 23:56:33 Timothy Pearson
Disable SHM access between XUP and Xorg as they are not running on the same machine
M xorg/X11R7.6/rdp/rdpup.c

xorg/X11R7.6/rdp/rdpup.c

diff --git a/xorg/X11R7.6/rdp/rdpup.c b/xorg/X11R7.6/rdp/rdpup.c
index 8352525..d9f691b 100644
--- a/xorg/X11R7.6/rdp/rdpup.c
+++ b/xorg/X11R7.6/rdp/rdpup.c
@@ -34,7 +34,7 @@
 #define LLOGLN(_level, _args) \
     do { if (_level < LOG_LEVEL) { ErrorF _args ; ErrorF("\n"); } } while (0)
 
-static int g_use_shmem = 1; /* turns on or off */
+static int g_use_shmem = 0; /* turns on or off */
 static int g_shmemid = 0;
 static char *g_shmemptr = 0;
 static int g_shmem_lineBytes = 0;
621b6978 2019-03-16 23:57:45 Timothy Pearson
Fix crash when SHM not available
Enhance debug logging of SHM related functions
M common/os_calls.c
M xup/xup.c

common/os_calls.c

diff --git a/common/os_calls.c b/common/os_calls.c
index 1d3a71b..c69024c 100644
--- a/common/os_calls.c
+++ b/common/os_calls.c
@@ -3168,12 +3168,12 @@
 }
 
 /*****************************************************************************/
-/* returns pointer or nil on error */
+/* returns pointer or -1 on error */
 void * APP_CC
 g_shmat(int shmid)
 {
 #if defined(_WIN32)
-    return 0;
+    return -1;
 #else
      return shmat(shmid, 0, 0);
 #endif

xup/xup.c

diff --git a/xup/xup.c b/xup/xup.c
index 0643cb3..89ca9f0 100644
--- a/xup/xup.c
+++ b/xup/xup.c
@@ -31,6 +31,7 @@
 #include <unistd.h>
 #include <fcntl.h>
 #include <netdb.h>
+#include <errno.h>
 
 /******************************************************************************/
 /**
@@ -1232,6 +1233,11 @@
         {
             mod->screen_shmem_id = shmem_id;
             mod->screen_shmem_pixels = g_shmat(mod->screen_shmem_id);
+            if (mod->screen_shmem_pixels == (void *)-1)
+            {
+		mod->screen_shmem_pixels = 0;
+                log_message(LOG_LEVEL_ERROR, "g_shmat() returned error, errno: %d\nIs X11rdp running on the same host as xrdp?\n", errno);
+            }
         }
         if (mod->screen_shmem_pixels != 0)
         {
@@ -1341,6 +1347,11 @@
         {
             amod->screen_shmem_id = shmem_id;
             amod->screen_shmem_pixels = g_shmat(amod->screen_shmem_id);
+            if (amod->screen_shmem_pixels == (void *)-1)
+            {
+		amod->screen_shmem_pixels = 0;
+                log_message(LOG_LEVEL_ERROR, "g_shmat() returned error, errno: %d\nIs X11rdp running on the same host as xrdp?\n", errno);
+            }
         }
         if (amod->screen_shmem_pixels != 0)
         {