[PATCH] Handle -displayfd and an explicit display number sensibly
Jon TURNEY
jon.turney at dronecode.org.uk
Tue Mar 25 09:39:45 PDT 2014
On 24/03/2014 19:56, Kristian Høgsberg wrote:
> On Wed, Mar 19, 2014 at 7:26 AM, Jon TURNEY wrote:
>> Handle -displayfd and an explicit display number sensibly, e.g. use the
>> explicitly specified display number, and write it to the displayfd
>
> I don't think the two options were meant to be used together, but I
> can see how that would be useful. Non-signal based ready notification
> while letting the parent process pick the display is useful for
> Xwayland as well.
Well, in the alternative, the X server could exit with an error if -displayfd
and an explicit display number are used, but this seems more useful.
> The parent process creates the fd in our process environment and could
> pick 0 as the display fd. Let's initialize to -1 which is never a
> valid fd.
A very good point. Amended patch to account for this attached.
-------------- next part --------------
From 68382c191dfb8d285960c464bcb4fc934566ef34 Mon Sep 17 00:00:00 2001
From: Jon TURNEY <jon.turney at dronecode.org.uk>
Date: Mon, 11 Mar 2013 14:34:32 +0000
Subject: [PATCH] Handle -displayfd and an explicit display number sensibly
Handle -displayfd and an explicit display number sensibly, e.g. use the
explicitly specified display number, and write it to the displayfd
v2: displayfd might be 0, so use -1 as invalid value
Signed-off-by: Jon TURNEY <jon.turney at dronecode.org.uk>
---
dix/globals.c | 3 ++-
include/opaque.h | 1 +
os/connection.c | 11 +++++------
os/utils.c | 2 +-
4 files changed, 9 insertions(+), 8 deletions(-)
diff --git a/dix/globals.c b/dix/globals.c
index 9738e9c..eaa2afe 100644
--- a/dix/globals.c
+++ b/dix/globals.c
@@ -127,7 +127,8 @@ int defaultColorVisualClass = -1;
int monitorResolution = 0;
const char *display;
-int displayfd;
+int displayfd = -1;
+Bool explicit_display = FALSE;
char *ConnectionInfo;
CARD32 TimeOutValue = DEFAULT_TIMEOUT * MILLI_PER_SECOND;
diff --git a/include/opaque.h b/include/opaque.h
index 73d40c3..0d917b0 100644
--- a/include/opaque.h
+++ b/include/opaque.h
@@ -51,6 +51,7 @@ extern _X_EXPORT int defaultScreenSaverBlanking;
extern _X_EXPORT int defaultScreenSaverAllowExposures;
extern _X_EXPORT const char *display;
extern _X_EXPORT int displayfd;
+extern _X_EXPORT Bool explicit_display;
extern _X_EXPORT int defaultBackingStore;
extern _X_EXPORT Bool disableBackingStore;
diff --git a/os/connection.c b/os/connection.c
index ddf4f0a..7bc2d94 100644
--- a/os/connection.c
+++ b/os/connection.c
@@ -351,8 +351,8 @@ void
NotifyParentProcess(void)
{
#if !defined(WIN32)
- if (dynamic_display[0]) {
- write(displayfd, dynamic_display, strlen(dynamic_display));
+ if (displayfd >= 0) {
+ write(displayfd, display, strlen(display));
write(displayfd, "\n", 1);
close(displayfd);
}
@@ -404,15 +404,14 @@ CreateWellKnownSockets(void)
FD_ZERO(&WellKnownConnections);
/* display is initialized to "0" by main(). It is then set to the display
- * number if specified on the command line, or to NULL when the -displayfd
- * option is used. */
- if (display) {
+ * number if specified on the command line. */
+ if ((displayfd < 0) || explicit_display) {
if (TryCreateSocket(atoi(display), &partial) &&
ListenTransCount >= 1)
if (!PartialNetwork && partial)
FatalError ("Failed to establish all listening sockets");
}
- else { /* -displayfd */
+ else { /* -displayfd and no explicit display number */
Bool found = 0;
for (i = 0; i < 65535 - X_TCP_PORT; i++) {
if (TryCreateSocket(i, &partial) && !partial) {
diff --git a/os/utils.c b/os/utils.c
index 497779b..8ea6e7a 100644
--- a/os/utils.c
+++ b/os/utils.c
@@ -666,6 +666,7 @@ ProcessCommandLine(int argc, char *argv[])
else if (argv[i][0] == ':') {
/* initialize display */
display = argv[i];
+ explicit_display = TRUE;
display++;
if (!VerifyDisplayName(display)) {
ErrorF("Bad display name: %s\n", display);
@@ -736,7 +737,6 @@ ProcessCommandLine(int argc, char *argv[])
else if (strcmp(argv[i], "-displayfd") == 0) {
if (++i < argc) {
displayfd = atoi(argv[i]);
- display = NULL;
#ifdef LOCK_SERVER
nolock = TRUE;
#endif
--
1.8.3.4
More information about the xorg-devel
mailing list