aboutsummaryrefslogtreecommitdiff
path: root/nx-X11/programs/Xserver/os
diff options
context:
space:
mode:
authorMihai Moldovan <ionic@ionic.de>2017-04-20 18:24:04 +0200
committerMihai Moldovan <ionic@ionic.de>2017-04-20 18:24:04 +0200
commit1ccc6be6114044c5e56f7130c6e6b2836ef5b175 (patch)
tree5281628e570b043f2b5448e6c441b0be0edd5a72 /nx-X11/programs/Xserver/os
parent7d0b7055bf164761f1e6969efbb6af95c822da7d (diff)
parent9865f73beb421d389aeaaefc3c672bd3322e77f9 (diff)
downloadnx-libs-1ccc6be6114044c5e56f7130c6e6b2836ef5b175.tar.gz
nx-libs-1ccc6be6114044c5e56f7130c6e6b2836ef5b175.tar.bz2
nx-libs-1ccc6be6114044c5e56f7130c6e6b2836ef5b175.zip
Merge branch 'sunweaver-pr/enhance-displayfd-auto-detection' into 3.6.x
Attributes GH PR #419: https://github.com/ArcticaProject/nx-libs/pull/419
Diffstat (limited to 'nx-X11/programs/Xserver/os')
-rw-r--r--nx-X11/programs/Xserver/os/connection.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/nx-X11/programs/Xserver/os/connection.c b/nx-X11/programs/Xserver/os/connection.c
index 8a5eb756a..1b01e1c46 100644
--- a/nx-X11/programs/Xserver/os/connection.c
+++ b/nx-X11/programs/Xserver/os/connection.c
@@ -79,6 +79,7 @@ SOFTWARE.
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
+#include <unistd.h>
#ifndef WIN32
#include <sys/socket.h>
@@ -364,6 +365,14 @@ NotifyParentProcess(void)
{
#if !defined(WIN32)
if (displayfd >= 0) {
+#ifdef NXAGENT_SERVER
+ if (displayfd == STDERR_FILENO)
+ {
+ const char *msg = "Auto-detected display number is: DISPLAY=:";
+ if (write(displayfd, msg, strlen(msg)) != strlen(msg))
+ FatalError("Cannot write display number to fd %d\n", displayfd);
+ }
+#endif
if (write(displayfd, display, strlen(display)) != strlen(display))
FatalError("Cannot write display number to fd %d\n", displayfd);
if (write(displayfd, "\n", 1) != 1)
@@ -418,7 +427,11 @@ CreateWellKnownSockets(void)
if (NoListenAll) {
ListenTransCount = 0;
}
+#ifndef NXAGENT_SERVER
else if ((displayfd < 0) || explicit_display) {
+#else
+ else if (displayfd < 0) {
+#endif /* ! NXAGENT_SERVER */
if (TryCreateSocket(atoi(display), &partial) &&
ListenTransCount >= 1)
if (!PartialNetwork && partial)
@@ -426,7 +439,14 @@ CreateWellKnownSockets(void)
}
else { /* -displayfd and no explicit display number */
Bool found = 0;
+#ifdef NXAGENT_SERVER
+ int i_offset = 0;
+ if (explicit_display)
+ i_offset = atoi(display);
+ for (i = i_offset; i < 65536 - X_TCP_PORT; i++) {
+#else
for (i = 0; i < 65536 - X_TCP_PORT; i++) {
+#endif /* NXAGENT_SERVER */
if (TryCreateSocket(i, &partial) && !partial) {
found = 1;
break;