summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKristian Høgsberg <krh@bitplanet.net>2011-06-21 21:28:31 -0400
committerKristian Høgsberg <krh@bitplanet.net>2012-03-27 09:31:58 -0400
commit1d81034e55e518f21b8c18c9850a60020d564066 (patch)
tree0df73a81e719dc7616a470b56342a212e6fc3812
parent1bc09c62ab68fdb134211b67c110b8a6abaadf8e (diff)
os: Add a function to create a client for an fd
-rw-r--r--include/opaque.h1
-rw-r--r--include/os.h5
-rw-r--r--os/connection.c39
-rw-r--r--os/utils.c5
4 files changed, 40 insertions, 10 deletions
diff --git a/include/opaque.h b/include/opaque.h
index 5c707172c..a8e412f33 100644
--- a/include/opaque.h
+++ b/include/opaque.h
@@ -72,6 +72,7 @@ extern _X_EXPORT Bool whiteRoot;
extern _X_EXPORT Bool bgNoneRoot;
extern _X_EXPORT Bool CoreDump;
+extern _X_EXPORT Bool NoListenAll;
#endif /* OPAQUE_H */
diff --git a/include/os.h b/include/os.h
index 48ce32962..1f0150b3f 100644
--- a/include/os.h
+++ b/include/os.h
@@ -162,8 +162,9 @@ extern _X_EXPORT void MakeClientGrabImpervious(ClientPtr /*client*/);
extern _X_EXPORT void MakeClientGrabPervious(ClientPtr /*client*/);
-#ifdef XQUARTZ
-extern void ListenOnOpenFD(int /* fd */, int /* noxauth */);
+#if defined(XQUARTZ) || defined(XORG_WAYLAND)
+extern _X_EXPORT void ListenOnOpenFD(int /* fd */, int /* noxauth */);
+extern _X_EXPORT void AddClientOnOpenFD(int /* fd */);
#endif
extern _X_EXPORT CARD32 GetTimeInMillis(void);
diff --git a/os/connection.c b/os/connection.c
index 0e557a544..92db08739 100644
--- a/os/connection.c
+++ b/os/connection.c
@@ -65,6 +65,7 @@ SOFTWARE.
#include <dix-config.h>
#endif
+#include <xorg-server.h>
#ifdef WIN32
#include <X11/Xwinsock.h>
#endif
@@ -141,7 +142,7 @@ fd_set OutputPending; /* clients with reply/event data ready to go */
int MaxClients = 0;
Bool NewOutputPending; /* not yet attempted to write some new output */
Bool AnyClientsWriteBlocked; /* true if some client blocked on write */
-
+Bool NoListenAll; /* Don't establish any listening sockets */
static Bool RunFromSmartParent; /* send SIGUSR1 to parent process */
Bool RunFromSigStopParent; /* send SIGSTOP to our own process; Upstart (or
equivalent) will send SIGCONT back. */
@@ -386,11 +387,16 @@ CreateWellKnownSockets(void)
FD_ZERO (&WellKnownConnections);
- snprintf (port, sizeof(port), "%d", atoi (display));
+ if (!NoListenAll)
+ {
+ snprintf (port, sizeof(port), "%d", atoi (display));
+
+ _XSERVTransMakeAllCOTSServerListeners (port, &partial,
+ &ListenTransCount,
+ &ListenTransConns);
+ }
- if ((_XSERVTransMakeAllCOTSServerListeners (port, &partial,
- &ListenTransCount, &ListenTransConns) >= 0) &&
- (ListenTransCount >= 1))
+ if (ListenTransCount >= 1)
{
if (!PartialNetwork && partial)
{
@@ -415,7 +421,7 @@ CreateWellKnownSockets(void)
}
}
- if (!XFD_ANYSET (&WellKnownConnections))
+ if (!XFD_ANYSET (&WellKnownConnections) && !NoListenAll)
FatalError ("Cannot establish any listening sockets - Make sure an X server isn't already running");
#if !defined(WIN32)
OsSignal (SIGPIPE, SIG_IGN);
@@ -1256,7 +1262,7 @@ MakeClientGrabPervious(ClientPtr client)
}
}
-#ifdef XQUARTZ
+#if defined(XQUARTZ) || defined(XORG_WAYLAND)
/* Add a fd (from launchd) to our listeners */
void ListenOnOpenFD(int fd, int noxauth) {
char port[256];
@@ -1305,4 +1311,23 @@ void ListenOnOpenFD(int fd, int noxauth) {
#endif
}
+/* based on TRANS(SocketUNIXAccept) (XtransConnInfo ciptr, int *status) */
+void AddClientOnOpenFD(int fd)
+{
+ XtransConnInfo ciptr;
+ CARD32 connect_time;
+
+ ciptr = _XSERVTransReopenCOTSServer(5, fd, "@anonymous");
+
+ _XSERVTransSetOption(ciptr, TRANS_NONBLOCKING, 1);
+ ciptr->flags |= TRANS_NOXAUTH;
+
+ connect_time = GetTimeInMillis();
+
+ if (!AllocNewConnection(ciptr, fd, connect_time)) {
+ fprintf(stderr, "failed to create client for wayland server\n");
+ return;
+ }
+}
+
#endif
diff --git a/os/utils.c b/os/utils.c
index 6461ed591..736c1b80d 100644
--- a/os/utils.c
+++ b/os/utils.c
@@ -759,7 +759,10 @@ ProcessCommandLine(int argc, char *argv[])
else if ( strcmp( argv[i], "-nolisten") == 0)
{
if(++i < argc) {
- if (_XSERVTransNoListen(argv[i]))
+ if ( strcmp ( argv[i], "all" ) == 0) {
+ NoListenAll = TRUE;
+ nolock = TRUE;
+ } else if (_XSERVTransNoListen(argv[i]))
FatalError ("Failed to disable listen for %s transport",
argv[i]);
} else